Exemple #1
0
        internal static void BatchUnLock(List<VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5)
        {
            IEdmPos5 aPos;

            var batchUnlocker = (IEdmBatchUnlock2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchUnlock);
            var i = 0;
            var ppoSelection = new EdmSelItem[filesList.Count];
            foreach (var file in filesList)
            {
                var fileInfo = new FileInfo(file.LocalPartFileInfo);

                if (string.IsNullOrEmpty(fileInfo.Extension)) continue;
              
                IEdmFolder5 ppoRetParentFolder;
                IEdmFile5 aFile;
                try
                {
                    aFile = edmVault5.GetFileFromPath(fileInfo.FullName, out ppoRetParentFolder);
                }
                catch (Exception exception)
                {
                    Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm");
                    //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                    continue;
                }

                if (aFile != null)
                {
                    try
                    {
                        aPos = aFile.GetFirstFolderPosition();
                        var aFolder = aFile.GetNextFolder(aPos);

                        ppoSelection[i] = new EdmSelItem
                        {                            
                            mlDocID = aFile.ID,
                            mlProjID = aFolder.ID                            
                        };
                        i++;
                    }
                    catch (Exception exception)
                    {
                        Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm");
                        //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                    }                    
                }
            }

            // Add selections to the batch of files to check in
            batchUnlocker.AddSelection(edmVault5, ppoSelection);
            batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock);
            batchUnlocker.Comment = filesList[0].MessageForCheckOut;
            var fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed);
            aPos = fileList.GetHeadPosition();

            while (!(aPos.IsNull))
            {
                EdmSelectionObject poSel;
                fileList.GetNext2(aPos, out poSel);
            }
            batchUnlocker.UnlockFiles(0);
        }
        internal static void BatchUnLock(List <VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5)
        {
            IEdmPos5 aPos;

            var batchUnlocker = (IEdmBatchUnlock2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchUnlock);
            var i             = 0;
            var ppoSelection  = new EdmSelItem[filesList.Count];

            foreach (var file in filesList)
            {
                var fileInfo = new FileInfo(file.LocalPartFileInfo);

                if (string.IsNullOrEmpty(fileInfo.Extension))
                {
                    continue;
                }

                IEdmFolder5 ppoRetParentFolder;
                IEdmFile5   aFile;
                try
                {
                    aFile = edmVault5.GetFileFromPath(fileInfo.FullName, out ppoRetParentFolder);
                }
                catch (Exception exception)
                {
                    Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm");
                    //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                    continue;
                }

                if (aFile != null)
                {
                    try
                    {
                        aPos = aFile.GetFirstFolderPosition();
                        var aFolder = aFile.GetNextFolder(aPos);

                        ppoSelection[i] = new EdmSelItem
                        {
                            mlDocID  = aFile.ID,
                            mlProjID = aFolder.ID
                        };
                        i++;
                    }
                    catch (Exception exception)
                    {
                        Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm");
                        //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                    }
                }
            }

            // Add selections to the batch of files to check in
            batchUnlocker.AddSelection(edmVault5, ppoSelection);
            batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock);
            batchUnlocker.Comment = filesList[0].MessageForCheckOut;
            var fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed);

            aPos = fileList.GetHeadPosition();

            while (!(aPos.IsNull))
            {
                EdmSelectionObject poSel;
                fileList.GetNext2(aPos, out poSel);
            }
            batchUnlocker.UnlockFiles(0);
        }
Exemple #3
0
        internal static void BatchAddFiles(List<VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5)
        {
            goto m1;

            #region Dll                                 

            var edmVault7 = (IEdmVault7)edmVault5;
            AddinConvertTo.Classes.Batches.BatchAddFiles(edmVault7, ConvertVentsCadFiles(filesList));
            return;

            #endregion

            m1:

            #region Code

            List<string> stringList = new List<string>();

            #region Show

            //    filesList.Select(x => x.LocalPartFileInfo).ToList();
            //MessageBox.Show(stringList.Count.ToString(), "Count before");
            //stringList = stringList.Distinct().ToList();
            //MessageBox.Show(stringList.Count.ToString(), "Count after 2");

            #endregion
            
            foreach (var item in filesList.OrderBy(x=>x.LocalPartFileInfo))
            {
                var inf = new FileInfo(item.LocalPartFileInfo);
                if (stringList.Contains(inf.Name)) continue;
                stringList.Add(inf.FullName);
            }
            var files = "";

            foreach (var file in stringList.Distinct())
            {
                files = files + "\n" + file;
            }            

            files = "";

            try
            {
                var  poAdder = (IEdmBatchAdd2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchAdd);               

                foreach (var file in stringList.Distinct())
                {
                    var fileInfo = new FileInfo(file);
                    var directoryName = fileInfo.Directory.FullName;
                    files = files + $"\n File - {fileInfo.FullName} directory - {directoryName}";
                    poAdder.AddFileFromPathToPath(fileInfo.FullName, directoryName);
                }
                                
                try
                {
                    //MessageBox.Show(poAdder.CommitAdd(0, null).ToString());
                    poAdder.CommitAdd(-1, null);
                }
                catch (Exception exception)
                {
                    Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm");
                    //MessageBox.Show(e.Message + "\n" + e.StackTrace, "2");
                }
            }
            catch (Exception exception)
            {
                Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm");
                //MessageBox.Show(e.StackTrace, "BatchAddFiles");
            }
            finally
            {
                //MessageBox.Show(files);
            }

            #endregion
        }
        internal static void BatchAddFiles(List <VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5)
        {
            goto m1;

            #region Dll

            var edmVault7 = (IEdmVault7)edmVault5;
            AddinConvertTo.Classes.Batches.BatchAddFiles(edmVault7, ConvertVentsCadFiles(filesList));
            return;

            #endregion

m1:

            #region Code

            List <string> stringList = new List <string>();

            #region Show

            //    filesList.Select(x => x.LocalPartFileInfo).ToList();
            //MessageBox.Show(stringList.Count.ToString(), "Count before");
            //stringList = stringList.Distinct().ToList();
            //MessageBox.Show(stringList.Count.ToString(), "Count after 2");

            #endregion

            foreach (var item in filesList.OrderBy(x => x.LocalPartFileInfo))
            {
                var inf = new FileInfo(item.LocalPartFileInfo);
                if (stringList.Contains(inf.Name))
                {
                    continue;
                }
                stringList.Add(inf.FullName);
            }
            var files = "";

            foreach (var file in stringList.Distinct())
            {
                files = files + "\n" + file;
            }

            files = "";

            try
            {
                var poAdder = (IEdmBatchAdd2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchAdd);

                foreach (var file in stringList.Distinct())
                {
                    var fileInfo      = new FileInfo(file);
                    var directoryName = fileInfo.Directory.FullName;
                    files = files + $"\n File - {fileInfo.FullName} directory - {directoryName}";
                    poAdder.AddFileFromPathToPath(fileInfo.FullName, directoryName);
                }

                try
                {
                    //MessageBox.Show(poAdder.CommitAdd(0, null).ToString());
                    poAdder.CommitAdd(-1, null);
                }
                catch (Exception exception)
                {
                    Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm");
                    //MessageBox.Show(e.Message + "\n" + e.StackTrace, "2");
                }
            }
            catch (Exception exception)
            {
                Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm");
                //MessageBox.Show(e.StackTrace, "BatchAddFiles");
            }
            finally
            {
                //MessageBox.Show(files);
            }

            #endregion
        }