public void BatchAddFiles(List<TaskParam> listType)
        {
            poAdder = (IEdmBatchAdd2)HostingForm.Vault2.CreateUtility(EdmUtility.EdmUtil_BatchAdd);

            //var newFolder = vault.RootFolderPath;

            RootFolder = HostingForm.Vault1.RootFolderPath;

            // poAdder.AddFolderPath(newFolder, 0, (int)EdmBatchAddFolderFlag.Ebaff_Nothing);

            foreach (var fileName in listType)
            {
                poAdder.AddFileFromPathToPath(RootFolder + fileName.FolderPath + fileName.FileName, RootFolder + fileName.FolderPath, 0);
            }
            //poAdder.ShowDlg(this.Handle.ToInt32(), (int)EdmAddFileDlgFlag.Eafdf_Nothing, "Files and folders in the batch:", "Batch Items");

            var edmFileInfo = new EdmFileInfo[listType.Count];
            poAdder.CommitAdd(0, null, 0);

            //var idx = edmFileInfo.GetLowerBound(0);
            //string msg = "";

            //while (idx <= edmFileInfo.GetUpperBound(0))
            //{
            //    string row = null;
            //    row = "(" + edmFileInfo[idx].mbsPath + ") arg = " + Convert.ToString(edmFileInfo[idx].mlArg);

            //    if (edmFileInfo[idx].mhResult == 0)
            //    {
            //        row = row + " status = OK ";
            //    }
            //    else
            //    {
            //        string oErrName = "";
            //        string oErrDesc = "";

            //        vault.GetErrorString(edmFileInfo[idx].mhResult, out oErrName, out oErrDesc);
            //        row = row + " status = " + oErrName;
            //    }

            //    idx = idx + 1;
            //    msg = msg + " " + row;

            //}
        }
Exemple #2
0
        public static void AddFiles(IEdmVault7 vault, List <Files.Info> files)
        {
            Logger.Add($"Добавление в PDM {files?.Count} файлов");
            string msg = "";

            try
            {
                var result = default(bool);
                poAdder = (IEdmBatchAdd)vault.CreateUtility(EdmUtility.EdmUtil_BatchAdd);
                foreach (var file in files)
                {
                    fileNameErr = file.FolderPath + "\\" + file.FileName;
                    try
                    {
                        poAdder.AddFileFromPathToPath(file.FolderPath + "\\" + file.ConvertFile, file.FolderPath, 0, "", 0);
                    }
                    catch (Exception ex)
                    {
                        Logger.Add($"Ошибка при добавлении: {ex.Message} Path: {file.FullFilePath} IdPDM: {file.IdPDM} FolderID: {file.FolderID} Version: {file.CurrentVersion}");
                    }
                }

                var edmFileInfo = new EdmFileInfo[files.Count];

                result = Convert.ToBoolean(poAdder.CommitAdd(0, edmFileInfo, 0));
                var idx = edmFileInfo.GetLowerBound(0);

                while (idx <= edmFileInfo.GetUpperBound(0))
                {
                    string row = null;
                    row = "(" + edmFileInfo[idx].mbsPath + ") arg = " + Convert.ToString(edmFileInfo[idx].mlArg);

                    if (edmFileInfo[idx].mhResult == 0)
                    {
                        row = row + " status = OK " + edmFileInfo[idx].mbsPath;
                    }
                    else
                    {
                        string oErrName = "";
                        string oErrDesc = "";

                        vault.GetErrorString(edmFileInfo[idx].mhResult, out oErrName, out oErrDesc);
                        row = row + " status = " + oErrName;
                    }

                    idx = idx + 1;
                    msg = msg + "\n" + row;
                }

                //  statusChank = true;
            }
            catch (COMException ex)
            {
                Logger.Add("ERROR BatchAddFiles " + msg + ", file: " + fileNameErr + " HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message);
                //  statusChank = false;
            }

            #region To delete

            //try
            //{
            //    var result = default(bool);
            //    poAdder = (IEdmBatchAdd)vault.CreateUtility(EdmUtility.EdmUtil_BatchAdd);
            //    foreach (var fileName in listType)
            //    {
            //        fileNameErr = fileName.FolderPath + "\\" + fileName.FileName;
            //        poAdder.AddFileFromPathToPath(fileName.FolderPath + "\\" + fileName.ConvertFile, fileName.FolderPath, 0, "", 0);
            //    }
            //    var edmFileInfo = new EdmFileInfo[listType.Count];

            //    result = Convert.ToBoolean(poAdder.CommitAdd(0, edmFileInfo, 0));
            //    var idx = edmFileInfo.GetLowerBound(0);
            //    while (idx <= edmFileInfo.GetUpperBound(0))
            //    {
            //        string row = null;
            //        row = "(" + edmFileInfo[idx].mbsPath + ") arg = " + Convert.ToString(edmFileInfo[idx].mlArg);

            //        if (edmFileInfo[idx].mhResult == 0)
            //        {
            //            row = row + " status = OK " + edmFileInfo[idx].mbsPath;
            //        }
            //        else
            //        {
            //            string oErrName = "";
            //            string oErrDesc = "";

            //            vault.GetErrorString(edmFileInfo[idx].mhResult, out oErrName, out oErrDesc);
            //            row = row + " status = " + oErrName;
            //        }

            //        idx = idx + 1;
            //        msg = msg + "\n" + row;
            //    }
            //    statusChank = true;
            //}
            //catch (COMException ex)
            //{
            //    Logger.ToLog("ERROR BatchAddFiles " + msg + ", file: " + fileNameErr + " HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message, 10001);
            //    statusChank = false;
            //}

            #endregion
        }