void SwPartParamsChangeWithNewName(string partName, string newName, string[,] newParams, bool newFuncOfAdding)
        {
            try
            {
                Логгер.Информация($"Начало изменения детали {partName}", newName, null, "SwPartParamsChangeWithNewName");
                var swDoc = _swApp.OpenDoc6(partName + ".SLDPRT", (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0);

                var modName = swDoc.GetPathName();
                for (var i = 0; i < newParams.Length / 2; i++)
                {
                    try
                    {
                        var myDimension = ((Dimension)(swDoc.Parameter(newParams[i, 0] + "@" + partName + ".SLDPRT")));
                        var param = Convert.ToDouble(newParams[i, 1]); var swParametr = param;
                        myDimension.SystemValue = swParametr / 1000;
                        swDoc.EditRebuild3();
                    }
                    catch (Exception e)
                    {
                        Логгер.Ошибка(string.Format("Во время изменения детали {4} произошла ошибка при изменении параметров {0}={1}. {2} {3}",
                                                    newParams[i, 0], newParams[i, 1], e.TargetSite, e.Message, Path.GetFileNameWithoutExtension(modName)), newName, null, "SwPartParamsChangeWithNewName");
                    }
                }

                if (newName == "")
                {
                    return;
                }

                swDoc.EditRebuild3();
                swDoc.ForceRebuild3(false);


                if (!newFuncOfAdding)
                {
                    NewComponents.Add(new VaultSystem.VentsCadFile
                    {
                        LocalPartFileInfo = new FileInfo(newName + ".SLDPRT").FullName
                    });
                }

                if (newFuncOfAdding)
                {
                    NewComponents.Add(new VaultSystem.VentsCadFile
                    {
                        LocalPartFileInfo = new FileInfo(newName + ".SLDPRT").FullName,
                        PartIdSql         = Convert.ToInt32(newName.Substring(newName.LastIndexOf('-') + 1))
                    });
                }

                swDoc.SaveAs2(newName + ".SLDPRT", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true);
                _swApp.CloseDoc(newName + ".SLDPRT");
                Логгер.Информация($"Деталь {partName} изменена и сохранена по пути {new FileInfo(newName).FullName}", null, newName, "SwPartParamsChangeWithNewName");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
 internal static string LocalPath(string vault)
 {
     try
     {
         return(VaultSystem.GetSwEpdRootFolderPath(vault));
     }
     catch (Exception e)
     {
         Логгер.Ошибка(string.Format("В базе - {1}, не удалось получить корнувую папку ({0})", e.Message, vault), e.StackTrace, "Add", "LocalPath(string Vault)");
         return(null);
     }
 }
Example #3
0
 public static void GetLastVersionOfFile(string path)
 {
     try
     {
         IEdmFolder5 oFolder;
         GetEdmFile5(path, out oFolder).GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest);
     }
     catch (Exception exception)
     {
         Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetLastVersionOfFile", "SwEpdm");
         //MessageBox.Show(exception.Message + "\n" + exception.StackTrace);
     }
 }
Example #4
0
 public static void GetAsmFilesAsBuild(string path)
 {
     try
     {
         IEdmFolder5 oFolder;
         GetEdmFile5(path, out oFolder).GetFileCopy(0, 0, oFolder.ID,
                                                    (int)EdmGetFlag.EdmGet_Refs + (int)EdmGetFlag.EdmGet_RefsOnlyMissing + (int)EdmGetFlag.EdmGet_RefsOverwriteLocked);
     }
     catch (Exception exception)
     {
         Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetAsmFilesAsBuild", "SwEpdm");
         //MessageBox.Show(exception.Message + "\n" + exception.StackTrace, "Не удалось получить последнюю версию файлов из хранилища");
     }
 }
        internal static void GetLastVersionAsmPdm(string path, string vaultName)
        {
            try
            {
                Логгер.Информация($"Получение последней версии по пути {path}\nБаза - {vaultName}", null, "", "GetLastVersionPdm");

                VaultSystem.GetLastVersionOfFile(path);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\n" + e.StackTrace);
                Логгер.Ошибка($"Во время получения последней версии по пути {path} возникла ошибка!\nБаза - {vaultName}. {e.Message}", e.StackTrace, null, "GetLastVersionPdm");
            }
        }
Example #6
0
        public static void CheckInOutPdmNew(List <VaultSystem.VentsCadFile> filesList, bool registration, out List <VaultSystem.VentsCadFile> newFilesList)
        {
            BatchAddFiles(filesList, edmVault5);

            var newFiles      = filesList.Where(x => string.IsNullOrEmpty(x.MessageForCheckOut)).ToList();
            var filesToUpdate = filesList.Where(x => !string.IsNullOrEmpty(x.MessageForCheckOut)).ToList();

            try
            {
                if (newFiles?.Count > 0)
                {
                    BatchUnLock(newFiles, edmVault5);
                }
            }
            catch (Exception exception)
            {
                Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "CheckInOutPdmNew", "SwEpdm");
                //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }

            try
            {
                if (filesToUpdate?.Count > 0)
                {
                    BatchUnLock(filesToUpdate, edmVault5);
                }
            }
            catch (Exception exception)
            {
                Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "CheckInOutPdmNew", "SwEpdm");
                //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }

            newFilesList = new List <VaultSystem.VentsCadFile>();

            foreach (var file in filesList)
            {
                string fileName;
                int    fileIdPdm;
                GetIdPdm(file.LocalPartFileInfo, out fileName, out fileIdPdm, edmVault5);

                newFilesList.Add(new VaultSystem.VentsCadFile
                {
                    PartName          = fileName,
                    PartIdPdm         = fileIdPdm,
                    LocalPartFileInfo = file.LocalPartFileInfo,
                    PartIdSql         = file.PartIdSql
                });
            }
        }
 internal static void DelEquations(int index, IModelDoc2 swModel)
 {
     try
     {
         Логгер.Информация($"Удаление уравнения #{index} в модели {swModel.GetPathName()}", null, "", "DelEquations");
         var myEqu = swModel.GetEquationMgr();
         myEqu.Delete(index);
         swModel.EditRebuild3();
     }
     catch (Exception e)
     {
         Логгер.Ошибка($"Удаление уравнения #{index} в модели {swModel.GetPathName()}. {e.Message}", null, e.StackTrace, "DelEquations");
     }
 }
Example #8
0
 public static int GetLocalVersionOfFile(string path)
 {
     try
     {
         IEdmFolder5 oFolder;
         var         ver = GetEdmFile5(path, out oFolder);
         return(ver.CurrentVersion);
     }
     catch (Exception exception)
     {
         Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetLastVersionOfFile", "SwEpdm");
         //MessageBox.Show(exception.Message + "\n" + exception.StackTrace);
         return(0);
     }
 }
        internal void GetIdPdm(string path, out string fileName, out int fileIdPdm, out int curVer, out List <string> configurations)
        {
            fileName       = null;
            fileIdPdm      = 0;
            curVer         = 0;
            configurations = null;

            try
            {
                VaultSystem.GetIdPdm(path, out fileName, out fileIdPdm, out curVer, out configurations, false, VaultName);
            }
            catch (Exception e)
            {
                Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), path, "GetIdPdm");
            }
        }
 static void PartInfoToXml(string filePath)
 {
     try
     {
         if (filePath == "")
         {
             return;
         }
         var extension = Path.GetExtension(filePath);
         if (extension == null)
         {
             return;
         }
         if (extension.ToLower() != ".sldprt")
         {
             return;
         }
         var @class = new MakeDxfExportPartDataClass
         {
             PdmBaseName = VaultName
         };
         bool   isErrors;
         string newEdrwFileName;
         @class.CreateFlattPatternUpdateCutlistAndEdrawing(filePath, out newEdrwFileName, out isErrors, false, false, true, true);
         if (!isErrors)
         {
             Логгер.Информация("Закончена обработка детали " + Path.GetFileName(filePath), null, "", "PartInfoToXml");
         }
         else
         {
             List <VaultSystem.VentsCadFile> list;
             VaultSystem.CheckInOutPdmNew(new List <VaultSystem.VentsCadFile> {
                 new VaultSystem.VentsCadFile {
                     LocalPartFileInfo = newEdrwFileName
                 }
             }, true,                                                                                                                                       //   VaultName,
                                          out list);
             Логгер.Информация("Закончена обработка детали " + Path.GetFileName(filePath) + " с ошибками", null, "", "PartInfoToXml");
         }
     }
     catch (Exception e)
     {
         Логгер.Ошибка("Ошибка:" + e.Message, e.StackTrace, "SwEpdm", "AddToPdmByPath");
     }
 }
Example #11
0
        internal int GetPdmIds(string path, out int projectId)
        {
            var Id = 0;

            projectId = 0;
            try
            {
                IEdmFolder5 oFolder;
                Id        = GetEdmFile5(path, out oFolder).ID;
                projectId = oFolder.ID;
            }
            catch (Exception exception)
            {
                Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetPdmIds", "SwEpdm");
                //MessageBox.Show(exception.Message + "\n" + exception.StackTrace);
            }
            return(Id);
        }
Example #12
0
 internal static IEdmFile5 GetEdmFile5(string path, out IEdmFolder5 folder)
 {
     folder = null;
     try
     {
         IEdmFolder5 oFolder;
         var         edmFile5 = edmVault5.GetFileFromPath(path, out oFolder);
         edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest);
         folder = oFolder;
         return(edmFile5);
     }
     catch (Exception exception)
     {
         Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetEdmFile5", "SwEpdm");
         //MessageBox.Show(exception.Message + "\n" + exception.StackTrace + "\n" + path);
         return(null);
     }
 }
Example #13
0
        internal static void GetIdPdm(string path, out string fileName, out int fileIdPdm, EdmVault5 edmVault5)
        {
            fileName  = null;
            fileIdPdm = 0;
            try
            {
                IEdmFolder5 oFolder;
                var         tries = 1;
m1:
                Thread.Sleep(500);
                path = new FileInfo(path).FullName;

                var edmFile5 = edmVault5.GetFileFromPath(path, out oFolder);

                if (oFolder == null)
                {
                    tries++;
                    if (tries > 10)
                    {
                        return;
                    }
                    goto m1;
                }

                try
                {
                    edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest);
                }
                catch (Exception exception)
                {
                    Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm");
                    //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                }

                fileName  = edmFile5.Name;
                fileIdPdm = edmFile5.ID;
            }
            catch (Exception exception)
            {
                Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm");
                //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
Example #14
0
        public static void AddToPdmByPath(string path)
        {
            if (UseDll)
            {
                throw new Exception("!UseDll");
            }

            else
            {
                try
                {
                    var fileDirectory = new FileInfo(path).DirectoryName;

                    var fileFolder = edmVault5.GetFolderFromPath(fileDirectory);
                    fileFolder.AddFile(fileFolder.ID, "", Path.GetFileName(path));
                }
                catch (Exception e)
                {
                    Логгер.Ошибка("Ошибка:" + e.Message, e.StackTrace, "SwEpdm", "AddToPdmByPath");
                }
            }
        }
Example #15
0
        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);
            }
        }
Example #16
0
            public static void SearchDoc(string fileName, SwDocType swDocType, out List <FindedDocuments> fileList, string vaultName)
            {
                var files = new List <FindedDocuments>();

                try
                {
                    var edmVault7 = (IEdmVault7)edmVault5;

                    //Search for all text files in the edmVault7
                    var edmSearch5 = (IEdmSearch5)edmVault7.CreateUtility(EdmUtility.EdmUtil_Search);

                    var extenison = "";
                    var like      = "";

                    switch ((int)swDocType)
                    {
                    case 0:
                        extenison = "";
                        like      = "";
                        break;

                    case 1:
                        like      = "%";
                        extenison = ".sldprt";
                        break;

                    case 2:
                        like      = "%";
                        extenison = "%.sldasm";
                        break;

                    case 3:
                        like      = "%";
                        extenison = "%.slddrw";
                        break;

                    case 4:
                        like      = "%";
                        extenison = "%.%";
                        break;
                    }
                    edmSearch5.FileName = like + fileName + extenison;

                    var edmSearchResult5 = edmSearch5.GetFirstResult();

                    while (edmSearchResult5 != null)
                    {
                        files.Add(new FindedDocuments
                        {
                            PartIdPdm = edmSearchResult5.ID,
                            PartName  = edmSearchResult5.Name,
                            PartSize  = edmSearchResult5.FileSize,
                            ProjectId = edmSearchResult5.ParentFolderID,
                            Path      = edmSearchResult5.Path,
                            Time      = (DateTime)edmSearchResult5.FileDate
                        });
                        edmSearchResult5 = edmSearch5.GetNextResult();
                    }

                    if (edmSearch5.GetFirstResult() == null)
                    {
                        //LoggerInfo("Файл не найден!");
                        files = null;
                    }
                }

                catch (Exception exception)
                {
                    Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "SearchDoc", "SwEpdm");
                    //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                }
                fileList = files;
            }
Example #17
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);
        }
Example #18
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
        }
Example #19
0
        public static void GetIdPdm(string path, out string fileName, out int fileIdPdm, out int currentVerison, out List <string> configs, bool getFileCopy)
        {
            fileName       = null;
            fileIdPdm      = 0;
            currentVerison = 0;
            configs        = new List <string>();
            try
            {
                IEdmFolder5 oFolder;
                var         tries = 1;
m1:
                Thread.Sleep(500);
                path = new FileInfo(path).FullName;

                var edmFile5 = edmVault5.GetFileFromPath(path, out oFolder);

                if (oFolder == null)
                {
                    tries++;
                    if (tries > 10)
                    {
                        return;
                    }
                    goto m1;
                }

                if (getFileCopy)
                {
                    try
                    {
                        edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest);
                    }
                    catch (Exception exception)
                    {
                        Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm");
                        //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                    }
                }

                fileName       = edmFile5.Name;
                fileIdPdm      = edmFile5.ID;
                currentVerison = edmFile5.CurrentVersion;
                EdmStrLst5 list = edmFile5.GetConfigurations();

                IEdmPos5 pos = default(IEdmPos5);
                pos = list.GetHeadPosition();
                string cfgName = null;
                while (!pos.IsNull)
                {
                    cfgName = list.GetNext(pos);
                    if (cfgName == "@")
                    {
                        continue;
                    }
                    configs.Add(cfgName);
                }
            }
            catch (Exception exception)
            {
                Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm");
                //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
        static void GabaritsForPaintingCamera(IModelDoc2 swmodel)
        {
            try
            {
                const long valueset      = 1000;
                const int  swDocPart     = 1;
                const int  swDocAssembly = 2;

                var configNames = swmodel.GetConfigurationNames();

                foreach (var configname in configNames)
                {
                    try
                    {
                        IConfiguration swConf = swmodel.GetConfigurationByName(configname);
                        if (swConf.IsDerived())
                        {
                            continue;
                        }
                    }
                    catch (Exception)
                    {
                        //
                    }

                    swmodel.EditRebuild3();


                    switch (swmodel.GetType())
                    {
                    case swDocPart:
                    {
                        var part = (IPartDoc)swmodel;

                        var box = part.GetPartBox(true);

                        swmodel.AddCustomInfo3(configname, "Длина", 30, "");
                        swmodel.AddCustomInfo3(configname, "Ширина", 30, "");
                        swmodel.AddCustomInfo3(configname, "Высота", 30, "");

                        swmodel.CustomInfo2[configname, "Длина"] =
                            Convert.ToString(
                                Math.Round(Convert.ToDecimal((long)(Math.Abs(box[0] - box[3]) * valueset)), 0));
                        swmodel.CustomInfo2[configname, "Ширина"] =
                            Convert.ToString(
                                Math.Round(Convert.ToDecimal((long)(Math.Abs(box[1] - box[4]) * valueset)), 0));
                        swmodel.CustomInfo2[configname, "Высота"] =
                            Convert.ToString(
                                Math.Round(Convert.ToDecimal((long)(Math.Abs(box[2] - box[5]) * valueset)), 0));
                    }
                    break;

                    case swDocAssembly:
                    {
                        var swAssy = (AssemblyDoc)swmodel;
                        var boxAss = swAssy.GetBox((int)swBoundingBoxOptions_e.swBoundingBoxIncludeRefPlanes);

                        swmodel.AddCustomInfo3(configname, "Длина", 30, "");
                        swmodel.AddCustomInfo3(configname, "Ширина", 30, "");
                        swmodel.AddCustomInfo3(configname, "Высота", 30, "");

                        swmodel.CustomInfo2[configname, "Длина"] =
                            Convert.ToString(
                                Math.Round(Convert.ToDecimal((long)(Math.Abs(boxAss[0] - boxAss[3]) * valueset)), 0));
                        swmodel.CustomInfo2[configname, "Ширина"] =
                            Convert.ToString(
                                Math.Round(Convert.ToDecimal((long)(Math.Abs(boxAss[1] - boxAss[4]) * valueset)), 0));
                        swmodel.CustomInfo2[configname, "Высота"] =
                            Convert.ToString(
                                Math.Round(Convert.ToDecimal((long)(Math.Abs(boxAss[2] - boxAss[5]) * valueset)), 0));
                    }
                    break;
                    }
                }
            }
            catch (Exception e)
            {
                Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), null, "GabaritsForPaintingCamera");
            }
        }
        private static void VentsMatdll(IList <string> materialP1, IList <string> покрытие, string newName)
        {
            try
            {
                //MessageBox.Show("ApplyMaterial 1");

                //_swApp.ActivateDoc2(newName, true, 0);
                //var setMaterials = new SetMaterials();
                //ToSQL.Conn = ConnectionToSql;
                //var toSql = new ToSQL();

                //MessageBox.Show("ApplyMaterial 2");

                //setMaterials.ApplyMaterial("", "00",
                //    1700,
                //    //Convert.ToInt32(materialP1[0]),
                //    _swApp);
                //_swApp.IActiveDoc2.Save();

                //foreach (var confname in setMaterials.GetConfigurationNames(_swApp))
                //{
                //    foreach (var matname in setMaterials.GetCustomProperty(confname, _swApp))
                //    {
                //        toSql.AddCustomProperty(confname, matname.Name, _swApp);
                //    }
                //}

                //if (покрытие != null)
                //{
                //    if (покрытие[1] != "0")
                //    {
                //        setMaterials.SetColor("00", покрытие[0], покрытие[1], покрытие[2], _swApp);
                //    }
                //    _swApp.IActiveDoc2.Save();
                //}

                //try
                //{
                //    string message;
                //    setMaterials.CheckSheetMetalProperty("00", _swApp, out message);
                //    if (message != null)
                //    {
                //        MessageBox.Show(message, newName);
                //    }
                //}
                //catch (Exception e)
                //{
                //    MessageBox.Show(e.Message + "\n" + e.StackTrace, "VentsMatdll");
                //    Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), newName, "VentsMatdll");
                //}
            }

            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\n" + e.StackTrace, "VentsMatdll");
                Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), newName, "VentsMatdll");
            }

            finally
            {
                try
                {
                    GabaritsForPaintingCamera(_swApp.IActiveDoc2);
                    _swApp.IActiveDoc2.Save();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message + "\n" + e.StackTrace);
                    Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), newName, "VentsMatdll");
                }
            }
        }
Example #22
0
        public static void CheckInOutPdm(List <FileInfo> filesList, bool registration)
        {
            foreach (var file in filesList)
            {
                var retryCount = 2;
                var success    = false;
                while (!success && retryCount > 0)
                {
                    try
                    {
                        IEdmFolder5 oFolder;
                        var         edmFile5 = edmVault5.GetFileFromPath(file.FullName, out oFolder);

                        // Разрегистрировать
                        if (registration == false)
                        {
                            edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_Simple);
m1:
                            edmFile5.LockFile(oFolder.ID, 0);
                            //MessageBox.Show(edmFile5.Name);
                            Thread.Sleep(50);
                            var j = 0;
                            if (!edmFile5.IsLocked)
                            {
                                j++;
                                if (j > 5)
                                {
                                    goto m3;
                                }
                                goto m1;
                            }
                        }
                        // Зарегистрировать
                        if (registration)
                        {
m2:
                            edmFile5.UnlockFile(oFolder.ID, "");
                            Thread.Sleep(50);
                            var i = 0;
                            if (edmFile5.IsLocked)
                            {
                                i++;
                                if (i > 5)
                                {
                                    goto m4;
                                }
                                goto m2;
                            }
                        }
m3:
m4:
                        //LoggerInfo(string.Format("В базе PDM - {1}, зарегестрирован документ по пути {0}", file.FullName, vaultName), "", "CheckInOutPdm");
                        success = true;
                    }
                    catch (Exception exception)
                    {
                        Логгер.Ошибка($"Message - {exception.Message}\nfile.FullName - {file.FullName}\nStackTrace - {exception.StackTrace}", null, "CheckInOutPdm", "SwEpdm");
                        //MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                        retryCount--;
                        Thread.Sleep(200);
                        if (retryCount == 0)
                        {
                            //
                        }
                    }
                }
                if (!success)
                {
                    //LoggerError($"Во время регистрации документа по пути {file.FullName} возникла ошибка\nБаза - {vaultName}. {ex.Message}", "", "CheckInOutPdm");
                }
            }
        }