} = @"\\srvkb\SolidWorks Admin\DXF\"; // @"C:\DXF\"; void ExportToDxf() { if (IsBusy) { return; } try { Busy = $"Выгрузка разверток для {CurrentModel}"; FolderToSaveDxf = CurrentModel.ToLower().EndsWith("dprt") ? "детали" : CurrentModel.ToLower().Replace(".sldasm", ""); var pathToSave = Path.Combine(ParentFolderToSaveDxf, FolderToSaveDxf); Directory.CreateDirectory(pathToSave.ToUpper()); var listToExportLocal = new List <PartsListXml2>(); var files = ""; foreach (var item in ListToRun.Where(x => x.Dxf)) { try { Exception exc; string matId; double? thikness; var blob = Database.DatabaseFileRead(item.IdPmd, item.CurrentVersion, item.Конфигурация, out matId, out thikness, out exc); if (exc != null) { MessageBox.Show(exc.StackTrace); } if (blob != null) { Dxf.SaveByteToFile(blob, Path.Combine(pathToSave, item.НаименованиеБезРасширения.ToUpper().Replace("ВНС-", "") + "-" + item.Конфигурация + (string.IsNullOrEmpty(matId) ? "" : "-" + matId) + ((thikness == null || thikness == 0) ? "" : "-" + string.Format("{0:0.0}", thikness)).Replace(",", ".") + ".dxf")); } else { files = files + "\n" + item.Наименование + " idPdm - " + item.IdPmd + " Ver - " + item.CurrentVersion + " Conf - " + item.Конфигурация; listToExportLocal.Add(item); } } catch (Exception) { listToExportLocal.Add(item); } } listToExportLocal.AddRange(ListToRun.Where(x => !x.Dxf).ToList()); GetFiles(listToExportLocal, out _pdmFilesAfterGet); var exeptions = new List <string>(); foreach (var part in listToExportLocal) { Exception exception; List <Dxf.ResultList> resultList; List <Dxf.DxfFile> dxfFiles; Dxf.Save(Path.GetFullPath(part.Путь), pathToSave, OnlyInAsmConfigs ? part.Конфигурация : null, out exception, part.IdPmd, part.CurrentVersion, out dxfFiles, true, true, IncludeNonSheetParts); if (exception != null) { try { MessageBox.Show(exception.Message + "\n" + exception.StackTrace, "Exception"); } catch (Exception) { } } try { Dxf.AddToSql(dxfFiles, false, out resultList); foreach (var item in resultList) { if (item != null) { exeptions.Add($"{item.dxfFile.IdPdm}"); } } } catch (Exception) { } } if (exeptions?.Count > 0) { using (var sw = new StreamWriter(pathToSave + "\\Exceptions for " + FolderToSaveDxf.ToUpper() + ".txt")) { foreach (var item in exeptions) { sw.WriteLine(item + ","); } } } foreach (var process in Process.GetProcessesByName("SLDWORKS")) { process.Kill(); } } catch (Exception) { //MessageBox.Show(exception.StackTrace); } MessageBox.Show($"Выгрузка разверток {Path.GetFileNameWithoutExtension(ПутьКСборке)} завершена"); Busy = null; }
void ExportToXml() { if (IsBusy) { return; } try { Busy = $"Выгрузка {CurrentModel}"; if (!OnlyParts) { if (!ПутьКСборке.ToLower().EndsWith("dprt")) { List <Exception> excptions; PdmAsmBomToXml.AsmBomToXml.ВыгрузкаСборкиВXml(ПутьКСборке, out excptions); } } } catch (Exception) { // MessageBox.Show(exception.StackTrace); } GetFiles(ListToRun.Where(newComponent => !newComponent.Xml), out _pdmFilesAfterGet); // var list = _pdmFilesAfterGet.Where(x => !x.Equal).ToList(); //var sf = ""; //foreach (var item in list) //{ // sf = sf + "\nName - " + item.FileName + " Path - " + item.FilePath + " VerBG - " + item.VersionBeforeGet + " VerAG - " + item.VersionBeforeGet; //} //MessageBox.Show(sf, list?.Count.ToString()); try { foreach (var newComponent in ListToRun.Where(newComponent => !newComponent.Xml)) { using (var modelSw = new ModelSw()) { try { Exception exception; ExportXmlSql.Export(modelSw.GetSwWithPart(newComponent.Путь), newComponent.CurrentVersion, (int)newComponent.IdPmd, out exception); if (exception != null) { MessageBox.Show(exception.Message); } //modelSw.ExitSw(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } catch (Exception exception) { MessageBox.Show(exception.StackTrace); } MessageBox.Show($"Выгрузка {Path.GetFileNameWithoutExtension(ПутьКСборке)} завершена"); Busy = null; }