private void UpdateRow(DataGridViewRow row, V_SEPO_TFLEX_OBJ_SYNCH item) { row.Cells[0].Value = item.TFLEX_SECTION; row.Cells[1].Value = item.TFLEX_DOCSIGN; row.Cells[2].Value = item.SECTYPE_NAME; row.Cells[3].Value = item.BOTYPESHORTNAME; row.Cells[4].Value = item.BOSTATESHORTNAME; row.Cells[5].Value = item.FILEGROUPSHORTNAME; row.Cells[6].Value = item.OMPSECTIONNAME; row.Cells[7].Value = item.PARAM_DEPENDENCE; row.Cells[8].Value = item.PARAM; row.Cells[9].Value = item.PARAM_EXPRESSION; }
private DataGridViewRow AddRow(V_SEPO_TFLEX_OBJ_SYNCH item) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells( scene, item.TFLEX_SECTION, item.TFLEX_DOCSIGN, item.SECTYPE_NAME, item.BOTYPESHORTNAME, item.BOSTATESHORTNAME, item.FILEGROUPSHORTNAME, item.OMPSECTIONNAME, item.PARAM_DEPENDENCE, item.PARAM, item.PARAM_EXPRESSION ); row.Tag = item.ID; scene.Rows.Add(row); return(row); }
public V_SEPO_TFLEX_OBJ_SYNCH GetSynchObj(string section, string docSign, string sign, int objectType) { OracleCommand cmd = new OracleCommand(); cmd.Parameters.Add("section", section); cmd.Parameters.Add("docsign", (docSign == String.Empty) ? "0" : docSign); cmd.Parameters.Add("objtype", objectType); cmd.CommandText = @"select id, id_section, tflex_section, id_docsign, tflex_docsign, kotype, botype, botypename, botypeshortname, bostatecode, bostatename, bostateshortname, filegroup, filegroupname, filegroupshortname, owner, ownername, ompsection, ompsectionname, param_dependence, id_param, param, param_expression, id_sectype from omp_adm.v_sepo_tflex_obj_synch where tflex_section = :section and coalesce(tflex_docsign, '0') = :docsign and coalesce(sectype_sign, 0) = :objtype order by param_dependence desc"; cmd.Connection = Connection.GetInstance(); using (OracleDataReader rd = cmd.ExecuteReader()) { while (rd.Read()) { V_SEPO_TFLEX_OBJ_SYNCH synch = new V_SEPO_TFLEX_OBJ_SYNCH(); synch.ID = rd.GetDecimal(0); synch.ID_SECTION = rd.GetDecimal(1); synch.TFLEX_SECTION = rd.GetString(2); if (!rd.IsDBNull(3)) { synch.ID_DOCSIGN = rd.GetDecimal(3); } if (!rd.IsDBNull(4)) { synch.TFLEX_DOCSIGN = rd.GetString(4); } synch.KOTYPE = rd.GetDecimal(5); synch.BOTYPE = rd.GetDecimal(6); synch.BOTYPENAME = rd.GetString(7); synch.BOTYPESHORTNAME = rd.GetString(8); synch.BOSTATECODE = rd.GetDecimal(9); synch.BOSTATENAME = rd.GetString(10); synch.BOSTATESHORTNAME = rd.GetString(11); if (!rd.IsDBNull(12)) { synch.FILEGROUP = rd.GetDecimal(12); } if (!rd.IsDBNull(13)) { synch.FILEGROUPNAME = rd.GetString(13); } if (!rd.IsDBNull(14)) { synch.FILEGROUPSHORTNAME = rd.GetString(14); } if (!rd.IsDBNull(15)) { synch.OWNER = rd.GetDecimal(15); } if (!rd.IsDBNull(16)) { synch.OWNERNAME = rd.GetString(16); } synch.OMPSECTION = rd.GetDecimal(17); synch.OMPSECTIONNAME = rd.GetString(18); synch.PARAM_DEPENDENCE = rd.GetInt32(19); if (!rd.IsDBNull(20)) { synch.ID_PARAM = rd.GetInt32(20); } if (!rd.IsDBNull(21)) { synch.PARAM = rd.GetString(21); } if (!rd.IsDBNull(22)) { synch.PARAM_EXPRESSION = rd.GetString(22); } if (!rd.IsDBNull(23)) { synch.ID_SECTYPE = rd.GetInt32(23); } if (synch.PARAM_DEPENDENCE == 0 || synch.PARAM_DEPENDENCE == 1 && Regex.IsMatch(sign, synch.PARAM_EXPRESSION)) { return(synch); } } } return(null); }
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 элементы спецификации }