private void AddFiles(AddFile file) { _loadFile = file; if (file == AddFile.FILES) { using (OpenFileDialog opd = new OpenFileDialog()) { opd.Filter = Dialogs.GetFilters(Filters.SUPPORTED_FILES); opd.Multiselect = false; if (opd.ShowDialog().Equals(DialogResult.OK)) { _directory = Path.GetDirectoryName(opd.FileName); _folder = Path.GetFileName(_directory); RegConfig.Set <string>("InitialDirectory", _directory); StartLoadFiles(true); } } } else { using (FolderBrowserDialog fbd = new FolderBrowserDialog()) { fbd.Description = Titles.FOLDER_BROWSER; fbd.SelectedPath = _intialDirectory; if (fbd.ShowDialog().Equals(DialogResult.OK)) { _directory = fbd.SelectedPath; _folder = Path.GetFileName(_directory); RegConfig.Set <string>("InitialDirectory", _directory); StartLoadFiles(true); } } } }
private void AddFiles(AddFile file) { _loadFile = file; if (file == AddFile.FILES) { using (OpenFileDialog opd = new OpenFileDialog()) { opd.Filter = Dialogs.GetFilters(Filters.ALL); if (opd.ShowDialog().Equals(DialogResult.OK)) { txtEnvValue.Text = opd.FileName; } } } else { using (FolderBrowserDialog fbd = new FolderBrowserDialog()) { fbd.Description = Titles.FOLDER_BROWSER; fbd.SelectedPath = _intialDirectory; if (fbd.ShowDialog().Equals(DialogResult.OK)) { txtEnvValue.Text = fbd.SelectedPath; } } } }
public ActionResult Add() { var viewModel = new AddFile { FileName = string.Empty, TypeOfFile = "" }; return(View(viewModel)); }
// POST api/<controller> public void Post([FromBody] AddFile f) { try { f.AddNewFile(); } catch (Exception ex) { throw new Exception("Error in Add a New file" + ex); } }
// GET api/<controller> public IEnumerable <AddFile> Get(int lessonId, int courseId) { try { List <AddFile> af = new List <AddFile>(); AddFile f = new AddFile(); af = f.GetFiles(lessonId, courseId); return(af); } catch (Exception ex) { throw new Exception("error with getting the files" + ex); } }
public IActionResult UpdatePage(GetPageDetails form) { string res = ""; if (form.DefImage != null) { res = AddFile.AddImage(form.DefImage, form.Id); } var result = new List <String>(); if (form.Image != null) { result = AddFile.AddImages(form.Image, form.Id); } PageDetail det = new PageDetail(); det.Id = form.Id; det.Topic = form.Topic; det.SubTopic = form.SubTopic; det.Type = form.Type; det.Dis1 = form.Dis1; det.Dis2 = form.Dis2; det.Dis3 = form.Dis3; det.IsActive = true; det.District = form.District; det.Town = form.Town; det.Location = form.location; if (form.DefImage != null) { det.DefImage = res; } try { var im = _service.AddImageName(result, form.Id); var up = _service.UpdatePage(det); if (up && im) { return(Ok()); } return(BadRequest()); } catch { return(BadRequest()); } }
public IActionResult UploadImages([FromForm] ImagesUpload form) { try { var result = new List <String>(); if (form.Image != null) { result = AddFile.AddImages(form.Image, form.Id); } var im = _service.AddImageName(result, form.Id); return(Ok(im)); } catch { return(BadRequest()); } }
public ActionResult AddPost() { var viewModel = new AddFile { FileName = string.Empty, TypeOfFile = "" }; string folder = string.Empty; string extension = string.Empty; string view = string.Empty; if (TryUpdateModel(viewModel)) { switch (viewModel.TypeOfFile) { case "css": extension = ".css"; folder = "Styles"; view = "Index"; break; case "js": extension = ".js"; folder = "Scripts"; view = "JsEditor"; break; case "razor": extension = ".cshtml"; folder = "Views"; view = "ViewEditor"; break; } var filename = string.Format("{0}{1}", viewModel.FileName, extension); string path = System.Web.HttpContext.Current.Server.MapPath(string.Format("~/Themes/{0}/{1}/{2}", _siteThemeService.GetCurrentThemeName(), folder, filename)); if (System.IO.File.Exists(path)) { AddModelError("Filename error", T("This file already exist.Choose another filename!", viewModel.FileName)); } using (var f = System.IO.File.CreateText(path)) { } } return(RedirectToAction(view)); }
// [Produces("application/json")] // [Consumes("application/json")] public IActionResult Tests([FromForm] GetPageDetails form) { try { string res = ""; if (form.DefImage != null) { res = AddFile.AddImage(form.DefImage, form.Id); } var result = new List <String>(); if (form.Image != null) { result = AddFile.AddImages(form.Image, form.Id); } PageDetail det = new PageDetail(); det.Id = form.Id; det.Topic = form.Topic; det.SubTopic = form.SubTopic; det.Type = form.Type; det.Dis1 = form.Dis1; det.Dis2 = form.Dis2; det.Dis3 = form.Dis3; det.DefImage = res; det.UsersEmail = form.Author; det.District = form.District; det.Town = form.Town; det.Location = form.location; det.IsActive = true; if ((_service.AddPageDetails(det) && _service.AddImageName(result, form.Id))) { return(Ok(result)); } return(BadRequest()); } catch { return(BadRequest()); } }
public IActionResult Add(AddFile file) { Food food = new Food(); if (file.ImageUrl != null) { var extension = Path.GetExtension(file.ImageUrl.FileName); var newImageName = Guid.NewGuid() + extension; var location = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Images/", newImageName); var stream = new FileStream(location, FileMode.Create); file.ImageUrl.CopyTo(stream); food.ImageUrl = newImageName; } food.FoodName = file.FoodName; food.UnitPrice = file.UnitPrice; food.UnitsInStock = file.UnitsInStock; food.Description = file.Description; food.CategoryId = file.CategoryId; foodDal.Add(food); return(RedirectToAction("Index")); }
private void profileListBox_DoubleClick(object sender, EventArgs e) { if (workspaceListBox.SelectedItemIndices.Count > 0) { if (workspaceListBox.SelectedIndex < 0 || workspaceListBox.SelectedItem == null) { return; } if (!_isLoading) { ParseMessageEventArgs item = workspaceListBox.SelectedItem as ParseMessageEventArgs; if (item != null) { NewProfile(); _selectedWorkspace = _workspacse.GetProfile(item.LineHeader); if (_selectedWorkspace != null) { _workspaceTable = _selectedWorkspace.WorkspaceTable; _directory = _selectedWorkspace.Directory; _folder = _selectedWorkspace.Name; if (!string.IsNullOrEmpty(_directory)) { _loadFile = AddFile.FOLDER; StartLoadFiles(false); InitHistory(_workspaceTable); } } } else { _selectedWorkspace = null; } } else { panelLocked.Visible = panelLockedBody.Visible = true; timerLock.Enabled = true; } } }
protected override async Task <int> ExecuteOnExtractedPackage(string directoryPath) { var action = new AddFile { DestinationPath = this.Verb.DestinationPath, SourcePath = this.Verb.SourcePath, Force = this.Verb.Force }; var executor = new AddFileExecutor(directoryPath); try { await executor.Execute(action).ConfigureAwait(false); await this.Console.WriteSuccess($"File '{this.Verb.SourcePath}' has been imported into '{this.Verb.DestinationPath}'.").ConfigureAwait(false); } catch (AddFileExecutor.FileAlreadyExistsException alreadyExistsException) { await this.Console.WriteError($"File '{this.Verb.SourcePath}' could not be added because the destination file '{alreadyExistsException.FilePath}' already exists.").ConfigureAwait(false); await this.Console.WriteInfo("You can force replacement of the file by using --force switch.").ConfigureAwait(false); return(StandardExitCodes.ErrorResourceExists); } catch (Exception e) { await this.Console.WriteError($"File '{this.Verb.SourcePath}' could not be added to '{this.Verb.DestinationPath}'.").ConfigureAwait(false); await this.Console.WriteError(e.Message).ConfigureAwait(false); return(StandardExitCodes.ErrorGeneric); } return(StandardExitCodes.ErrorSuccess); }
private void create_Button_Click(object sender, EventArgs e) { var newF = new AddFile(AddPath); newF.Show(); }
public void Managing_list_Files(TreeNode node, bool ClsChildNodes) { //должны быть ключи - именами, а значения - путями :) if (node.Checked) { if (!list_files.ContainsKey(node.Tag)) { list_files.Add(node.Tag, node.Tag); if (AddFile != null) { AddFile.Invoke(node.Tag); } } Hashtable to_remove = new Hashtable(20); foreach (object path in list_files.Keys) { string input = string.Empty; string pattern = string.Empty; if (path.ToString().Length > node.Tag.ToString().Length) { input = path.ToString(); pattern = node.Tag.ToString(); } else { input = node.Tag.ToString(); pattern = path.ToString(); } bool cmp = input.Contains(pattern); //если выбранная папка ближе к корню, чем ранее выбранная if ((cmp) && //так вот если она есть (path.ToString() != node.Tag.ToString()) && //и не равна самой себе (path.ToString().Split(Convert.ToChar("\\")).Length != node.Tag.ToString().Split(Convert.ToChar("\\")).Length) //и их уровни вложенности разные ) { if (!to_remove.ContainsKey((object)input)) { to_remove.Add((object)input, (object)input); } if (RemoveFile != null) { RemoveFile.Invoke(path); } } } foreach (object path in to_remove.Keys) { list_files.Remove((object)path); } if (ClsChildNodes) { node.Nodes.Clear(); } //MessageBox.Show(list_files.Count.ToString() + "/" + to_remove.Count.ToString()); } else { list_files.Remove(node.Tag); if (RemoveFile != null) { RemoveFile.Invoke(node.Tag); } } }
public static void AddFilesToDb() { try { long counter = 0; #if DEBUG stopwatch.Restart(); #endif foreach (KeyValuePair <string, DbOsFile> kvp in Context.Hashes) { UpdateProgress?.Invoke(null, "Adding files to database", counter, Context.Hashes.Count); if (!dbCore.DbOps.ExistsFile(kvp.Value.Sha256)) { DbFile file = new DbFile { Sha256 = kvp.Value.Sha256, ClamTime = null, Crack = kvp.Value.Crack, Length = kvp.Value.Length, Virus = null, HasVirus = null, VirusTotalTime = null }; dbCore.DbOps.AddFile(file); AddFile?.Invoke(file); } counter++; } #if DEBUG stopwatch.Stop(); Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all files to the database", stopwatch.Elapsed.TotalSeconds); #endif UpdateProgress?.Invoke(null, "Adding OS information", counter, Context.Hashes.Count); dbCore.DbOps.AddOs(Context.DbInfo, out Context.DbInfo.Id); UpdateProgress?.Invoke(null, "Creating OS table", counter, Context.Hashes.Count); dbCore.DbOps.CreateTableForOs(Context.DbInfo.Id); #if DEBUG stopwatch.Restart(); #endif counter = 0; foreach (KeyValuePair <string, DbOsFile> kvp in Context.Hashes) { UpdateProgress?.Invoke(null, "Adding files to OS in database", counter, Context.Hashes.Count); dbCore.DbOps.AddFileToOs(kvp.Value, Context.DbInfo.Id); counter++; } #if DEBUG stopwatch.Stop(); Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all files to the OS in the database", stopwatch.Elapsed.TotalSeconds); stopwatch.Restart(); #endif counter = 0; foreach (KeyValuePair <string, DbFolder> kvp in Context.FoldersDict) { UpdateProgress?.Invoke(null, "Adding folders to OS in database", counter, Context.FoldersDict.Count); dbCore.DbOps.AddFolderToOs(kvp.Value, Context.DbInfo.Id); counter++; } #if DEBUG stopwatch.Stop(); Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all folders to the database", stopwatch.Elapsed.TotalSeconds); stopwatch.Restart(); #endif counter = 0; if (Context.SymlinksDict.Count > 0) { dbCore.DbOps.CreateSymlinkTableForOs(Context.DbInfo.Id); } foreach (KeyValuePair <string, string> kvp in Context.SymlinksDict) { UpdateProgress?.Invoke(null, "Adding symbolic links to OS in database", counter, Context.SymlinksDict.Count); dbCore.DbOps.AddSymlinkToOs(kvp.Key, kvp.Value, Context.DbInfo.Id); counter++; } #if DEBUG stopwatch.Stop(); Console.WriteLine("Core.AddFilesToDb(): Took {0} seconds to add all symbolic links to the database", stopwatch.Elapsed.TotalSeconds); #endif Finished?.Invoke(); } catch (ThreadAbortException) { } catch (Exception ex) { if (Debugger.IsAttached) { throw; } Failed?.Invoke($"Exception {ex.Message}\n{ex.InnerException}"); #if DEBUG Console.WriteLine("Exception {0}\n{1}", ex.Message, ex.InnerException); #endif } }
private void ExportStructure(ProductStructure structure, bool isConfig = false) { // верификация структуры IsValidStructure(structure); // текущий документ Document currentDoc = structure.Document; // схема структуры SchemeDataConfig schemeConfig = new SchemeDataConfig(structure); SchemeData scheme = schemeConfig.GetScheme(); // родительский элемент RowElement parentItem = structure.GetAllRowElements().Where( x => x.ParentRowElement == null).FirstOrDefault(); ElementDataConfig dataConfig = new ElementDataConfig(parentItem, scheme); ElementData itemData = dataConfig.ConfigData(); // если структура является исполнением, то обозначением головного элемента // является наименование структуры if (isConfig) { itemData.Sign = structure.Name; } // логирование log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(); // команды TFlexObjSynchRepository synchRep = new TFlexObjSynchRepository(); // родительский элемент decimal?parent = null; // код БД decimal code = 0; decimal doccode = 0; // синхронизация с КИС "Омега" V_SEPO_TFLEX_OBJ_SYNCH synchObj = synchRep.GetSynchObj( itemData.MainSection, itemData.DocCode, itemData.Sign, itemData.ObjectType); // если головной элемент не синхронизирован - выход if (synchObj == null) { return; } #region экспорт родителя switch (synchObj.KOTYPE) { case (decimal)ObjTypes.SpecFixture: #region Спецификация оснастки CreateSpecFix.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // очищение спецификации ClearSpecification.Exec(code); // родительский элемент parent = code; // поиск файла спецификации по шаблону string signPattern = Regex.Replace(itemData.Sign, @"\D", ""); string[] files = Directory.GetFiles(currentDoc.FilePath); foreach (var file in files) { if (file.Contains(itemData.Sign) && file.Contains("СП")) { AddFile.Exec(code, file, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } } #endregion Спецификация оснастки break; case (decimal)ObjTypes.SpecDraw: #region Сборочный чертеж CreateSpecDraw.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); #endregion Сборочный чертеж break; case (decimal)ObjTypes.Document: case (decimal)ObjTypes.UserDocument: #region Документация CreateDocument.Exec( synchObj.BOTYPE, itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); #endregion Документация break; case (decimal)ObjTypes.Detail: #region Деталь CreateDetail.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); // модели для детали var models = structure.GetAllRowElements().Where(x => x.ParentRowElement == parentItem); foreach (var model in models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } // моделями также являются невидимые фрагменты у деталей foreach (var fragment in currentDoc.GetFragments().Where(x => !x.Visible)) { if (fragment.FullFilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = null; log.Position = null; log.Sign = null; log.Name = null; log.Qty = null; log.Doccode = null; log.FilePath = fragment.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, fragment.FullFilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } #endregion Деталь break; case (decimal)ObjTypes.Fixture: #region Оснастка CreateFixture.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); // модели для детали var fix_models = structure.GetAllRowElements().Where(x => x.ParentRowElement == parentItem); foreach (var model in fix_models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } // моделями также являются невидимые фрагменты у деталей foreach (var fragment in currentDoc.GetFragments().Where(x => !x.Visible)) { if (fragment.FullFilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = null; log.Position = null; log.Sign = null; log.Name = null; log.Qty = null; log.Doccode = null; log.FilePath = fragment.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, fragment.FullFilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } #endregion Оснастка break; default: break; } #endregion экспорт родителя #region элементы спецификации if (itemData.MainSection == "Сборочные единицы") { foreach (var elem in structure .GetAllRowElements() .Where(x => x.ParentRowElement == parentItem) ) { // получение данных о документе dataConfig = new ElementDataConfig(elem, scheme); itemData = dataConfig.ConfigData(); // логирование log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(); // если обозначение или секция пустые, то переход на следующий элемент if (itemData.Sign == String.Empty || itemData.Section == String.Empty) { continue; } //System.Windows.Forms.MessageBox.Show(itemData.SignFull + " |" + itemData.Section + " | " // + itemData.MainSection + " | " + itemData.ObjectType); // синхронизация с КИС "Омега" synchObj = synchRep.GetSynchObj( itemData.MainSection, itemData.DocCode, itemData.Sign, itemData.ObjectType); // переход на следующий элемент, если позиция не синхронизирована if (synchObj == null) { continue; } switch (synchObj.KOTYPE) { case (decimal)ObjTypes.SpecFixture: #region Спецификация оснастки CreateSpecFix.Exec( itemData.SignFull, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // очищение спецификации ClearSpecification.Exec(code); // если у сборки есть фрагмент... if (itemData.FilePath != null) { try { if (!File.Exists(itemData.FilePath)) { throw new FileNotFoundException(); } // открыть документ входящей сборки в режиме чтения Document linkDoc = TFlex.Application.OpenDocument(itemData.FilePath, false, true); // добавить документ в стек stackDocs.Add(linkDoc); // экспорт документа ExportDoc(linkDoc, itemData.SignFull); // закрытие документа linkDoc.Close(); // удалить из стека документ stackDocs.Remove(linkDoc); } catch (FileNotFoundException e) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(e); } catch (Exception) { throw; } } #endregion Спецификация оснастки break; case (decimal)ObjTypes.SpecDraw: #region Сборочный чертеж CreateSpecDraw.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); #endregion Сборочный чертеж break; case (decimal)ObjTypes.Document: case (decimal)ObjTypes.UserDocument: #region Документация CreateDocument.Exec( synchObj.BOTYPE, itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // файл if (itemData.FilePath != null) { AddFile.Exec(code, itemData.FilePath, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } #endregion Документация break; case (decimal)ObjTypes.Detail: #region Деталь CreateDetail.Exec( itemData.SignFull, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // файл if (itemData.FilePath != null) { AddFile.Exec(code, itemData.FilePath, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } // модели для детали var models = structure.GetAllRowElements().Where(x => x.ParentRowElement == elem); foreach (var model in models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, (doccode == 0) ? null : (decimal?)doccode, fileAdditional, ref linkdoccode); } } // открывается документ на деталь, если есть if (itemData.FilePath != null) { try { if (!File.Exists(itemData.FilePath)) { throw new FileNotFoundException(); } // открыть документ входящей сборки в режиме чтения Document linkDoc = TFlex.Application.OpenDocument(itemData.FilePath, false, true); // добавить документ в стек stackDocs.Add(linkDoc); // экспорт документа ExportDoc(linkDoc, itemData.SignFull); // закрытие документа linkDoc.Close(); // удалить из стека документ stackDocs.Remove(linkDoc); } catch (FileNotFoundException e) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(e); } catch (Exception) { throw; } } #endregion Деталь break; case (decimal)ObjTypes.Fixture: #region Оснастка CreateFixture.Exec( itemData.SignFull, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // файл if (itemData.FilePath != null) { AddFile.Exec(code, itemData.FilePath, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } // модели для детали var fix_models = structure.GetAllRowElements().Where(x => x.ParentRowElement == elem); foreach (var model in fix_models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.Exec(code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, (doccode == 0) ? null : (decimal?)doccode, fileAdditional, ref linkdoccode); } } // открывается документ на деталь, если есть if (itemData.FilePath != null) { try { if (!File.Exists(itemData.FilePath)) { throw new FileNotFoundException(); } // открыть документ входящей сборки в режиме чтения Document linkDoc = TFlex.Application.OpenDocument(itemData.FilePath, false, true); // добавить документ в стек stackDocs.Add(linkDoc); // экспорт документа ExportDoc(linkDoc, itemData.SignFull); // закрытие документа linkDoc.Close(); // удалить из стека документ stackDocs.Remove(linkDoc); } catch (FileNotFoundException e) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(e); } catch (Exception) { throw; } } #endregion Оснастка break; default: code = 0; break; } // добавить очередной элемент в спецификацию if (code != 0) { AddElement.Exec( parent.Value, code, synchObj.KOTYPE, synchObj.OMPSECTION, itemData.Qty.Value, itemData.Position, ompUserCode); } } } #endregion элементы спецификации }