Untitled diff

Created Diff never expires
20 removals
762 lines
29 additions
772 lines
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// scr_DataflowUtils
// scr_DataflowUtils
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
var DataflowUtils = new Object();
var DataflowUtils = new Object();
var DataflowNodeName = 'Dataflow';
var DataflowNodeName = 'Dataflow';
var ItemNodeName = 'Item';
var ItemNodeName = 'Item';
var ItemsNodeName = 'Items';
var ItemsNodeName = 'Items';
var SettingsNodeName = 'Settings';
var SettingsNodeName = 'Settings';
var DestinationNodeName = 'Destination';
var DestinationNodeName = 'Destination';
var ColumnsNodeName = 'Columns';
var ColumnsNodeName = 'Columns';
var BackRelationsNodeName = 'BackRelations';
var BackRelationsNodeName = 'BackRelations';
var EnumNodeName = 'Enum';
var EnumNodeName = 'Enum';
var EnumItemNodeName = 'EnumItem';
var EnumItemNodeName = 'EnumItem';
var NameAttributeName = 'Name';
var NameAttributeName = 'Name';
var SourceNameAttributeName = 'SourceName';
var SourceNameAttributeName = 'SourceName';
var RootTableSQLNameAttributeName = 'RootTableSQLName';
var RootTableSQLNameAttributeName = 'RootTableSQLName';
var FirstRowAttributeName = 'FirstRow';
var FirstRowAttributeName = 'FirstRow';
var FirstColumnAttributeName = 'FirstColumn';
var FirstColumnAttributeName = 'FirstColumn';
var LastColumnAttributeName = 'LastColumn';
var LastColumnAttributeName = 'LastColumn';
var IsFirstHeaderAttributeName = 'IsFirstHeader';
var IsFirstHeaderAttributeName = 'IsFirstHeader';
var ValueAttributeName = 'Value';
var ValueAttributeName = 'Value';
var TypeAttributeName = 'Type';
var TypeAttributeName = 'Type';
var IsDefaultAttributeName = 'IsDefault';
var IsDefaultAttributeName = 'IsDefault';
var IsPrimaryAttributeName = 'IsPrimary';
var IsPrimaryAttributeName = 'IsPrimary';
var ForeignKeyFieldAttributeName = 'ForeignKeyField';
var ForeignKeyFieldAttributeName = 'ForeignKeyField';
var IDAttributeName = 'ID';
var IDAttributeName = 'ID';
var TempFieldNameAttributeName = 'TempFieldName';
var TempFieldNameAttributeName = 'TempFieldName';
var TempIndexAttributeName = 'TempIndex';
var TempIndexAttributeName = 'TempIndex';
var FileBodyAttributeName = 'FileBody';
var FileBodyAttributeName = 'FileBody';
var gtPrimaryKeys = 0;
var gtPrimaryKeys = 0;
var gtDefaultValues = 1;
var gtDefaultValues = 1;
var gtEnumItems = 2;
var gtEnumItems = 2;
var ErrorDelimiter = '***';
var ErrorDelimiter = '***';
var ErrorIndent = '***';
var ErrorIndent = '***';
var WarningIndent = '-----';
var WarningIndent = '-----';
var InformationIndent = ' ';
var InformationIndent = ' ';
var EnumItemValueDelimiter = ';'
var EnumItemValueDelimiter = ';'
//TODO
var msgDeletePrimaryKeysConfirmation =
var msgDeletePrimaryKeysConfirmation =
"Вы действительно хотите удалить первичные ключи?";
"Вы действительно хотите удалить первичные ключи?";
//TODO
var msgDeleteDefaultValuesConfirmation =
var msgDeleteDefaultValuesConfirmation =
"Вы действительно хотите удалить значения по умолчанию?";
"Вы действительно хотите удалить значения по умолчанию?";
//TODO
var msgDeleteColumnConfirmation =
var msgDeleteColumnConfirmation =
"Вы действительно хотите удалить колонку?";
"Вы действительно хотите удалить колонку?";
//TODO
var msgFieldIsAssignedToColumn =
var msgFieldIsAssignedToColumn =
"Поле уже привязано к колонке. Продолжить?"
"Поле уже привязано к колонке. Продолжить?"
var msgFieldIsDefaultValue =
var msgFieldIsDefaultValue =
"Полю уже назначено значение по умолчанию. Продолжить?";
"Полю уже назначено значение по умолчанию. Продолжить?";
//TODO
var msgFieldIsPrimaryDisplay =
var msgFieldIsPrimaryDisplay =
"Поле является первичным для отображения. Добавить в первичный ключ?";
"Поле является первичным для отображения. Добавить в первичный ключ?";
var msgDataflowTypeIsNotDefined =
var msgDataflowTypeIsNotDefined =
"Тип интеграции не определен";
"Тип интеграции не определен";
var msgDataflowOperationIsNotDefined =
"Операция невозможна для даного типа интеграции";
var msgSelectFileForImport =
var msgSelectFileForImport =
"Выберите файл для импорта"
"Выберите файл для импорта"
var msgDestinationNodeNotFound =
var msgDestinationNodeNotFound =
"Узел 'Destination' не найден";
"Узел 'Destination' не найден";
var msgSettingsNodeNotFound =
var msgSettingsNodeNotFound =
"Узел 'Settings' не найден";
"Узел 'Settings' не найден";
var msgDatasetWasNotCreated =
var msgDatasetWasNotCreated =
"Набор данных не был сформирован";
"Набор данных не был сформирован";
var msgImportDataToTable =
var msgImportDataToTable =
"Импортируются данные в таблицу '%1'";
"Импортируются данные в таблицу '%1'";
var msgImportDataToTableFinished =
var msgImportDataToTableFinished =
"Импорт данных в таблицу '%1' завершен. Добавлено: %2. Обновлено: %3.";
"Импорт данных в таблицу '%1' завершен. Добавлено: %2. Обновлено: %3.";
//TODO
var msgPrimaryKeysDoesntExistsSkip =
var msgPrimaryKeysDoesntExistsSkip =
"Первичные поля не существуют. Таблица пропускается.";
"Первичные поля не существуют. Таблица пропускается.";
var msgImportRecord =
var msgImportRecord =
"Импортируется запись %1";
"Импортируется запись %1";
var msgRecordIsAlreadyImported =
var msgRecordIsAlreadyImported =
"Запись уже была проимпортирована";
"Запись уже была проимпортирована";
//TODO
var msgPrimaryKeyIsEmptySkip =
var msgPrimaryKeyIsEmptySkip =
"Первичное поле '%1' пустое. Запись пропускается.";
"Первичное поле '%1' пустое. Запись пропускается.";
var msgUnsupportedNodeType =
var msgUnsupportedNodeType =
"Недопустимый тип узла";
"Недопустимый тип узла";
var msgInsertRecord =
var msgInsertRecord =
"Запись добавлена";
"Запись добавлена";
var msgUpdateRecord =
var msgUpdateRecord =
"Запись обновлена";
"Запись обновлена";
var msgLookupWasNotImported =
var msgLookupWasNotImported =
"Справочник для поля '%1' не был проимпортирован";
"Справочник для поля '%1' не был проимпортирован";
var msgLookupIsNotDefined =
var msgLookupIsNotDefined =
"Справочник для поля '%1' не определен";
"Справочник для поля '%1' не определен";
var msgWrangDEfaultValue =
var msgWrangDEfaultValue =
"Некорректно определено значение по умолчанию для поля '%1'";
"Некорректно определено значение по умолчанию для поля '%1'";
var msgDatafieldIsNotDefined =
var msgDatafieldIsNotDefined =
"Не определено поле в наборе данных для поля '%1'";
"Не определено поле в наборе данных для поля '%1'";
var msgUpdateRecordIsNotNeed =
var msgUpdateRecordIsNotNeed =
"Нет необходимости обновлять запись";
"Нет необходимости обновлять запись";
var msgCantImportTableSkip =
var msgCantImportTableSkip =
"Невозможно импортировать данные. Таблица пропускается.";
"Невозможно импортировать данные. Таблица пропускается.";
var msgImportInterruptedbyUser =
var msgImportInterruptedbyUser =
"Импорт прерван пользователем";
"Импорт прерван пользователем";
var msgExecuteImportFromFile =
var msgExecuteImportFromFile =
"Импортируются данные из файла '%1'";
"Импортируются данные из файла '%1'";
var msgTableIsNotAssigned =
var msgTableIsNotAssigned =
"Таблица не указана";
"Таблица не указана";
var msgDoYouWantLookImportLog =
var msgDoYouWantLookImportLog =
"Импорт завершен. Показать журнал процесса импорта?";
"Импорт завершен. Показать журнал процесса импорта?";
var msgDataflowWasChanged =
var msgDataflowWasChanged =
"Настройки интеграции были изменены. Сохранить изменения?"
"Настройки интеграции были изменены. Сохранить изменения?"
function NotifyParentWindow(Window, Message, Data) {
function NotifyParentWindow(Window, Message, Data) {
var ParentWindow = Window.Attributes('ParentWindow');
var ParentWindow = Window.Attributes('ParentWindow');
ParentWindow.Notify(Window, Message, Data);
ParentWindow.Notify(Window, Message, Data);
}
}
function AddCommonRecord(Dataset, ID, ParentID, RecordType, Caption, HasChild){
function AddCommonRecord(Dataset, ID, ParentID, RecordType, Caption, HasChild){
Dataset.Append();
Dataset.Append();
Dataset.Values('ID') = ID;
Dataset.Values('ID') = ID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('RecordType') = RecordType;
Dataset.Values('RecordType') = RecordType;
Dataset.Values('Caption') = Caption;
Dataset.Values('Caption') = Caption;
Dataset.Values('HasChild') = HasChild;
Dataset.Values('HasChild') = HasChild;
Dataset.Post();
Dataset.Post();
}
}
function AddPrimaryKeyRecord(Dataset, ID, ParentID, Caption, HasChild){
function AddPrimaryKeyRecord(Dataset, ID, ParentID, Caption, HasChild){
Dataset.Append();
Dataset.Append();
Dataset.Values('ID') = ID;
Dataset.Values('ID') = ID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('RecordType') = rtcField;
Dataset.Values('RecordType') = rtcField;
Dataset.Values('Caption') = Caption;
Dataset.Values('Caption') = Caption;
Dataset.Values('IsPrimaryKey') = true;
Dataset.Values('IsPrimaryKey') = true;
Dataset.Values('HasChild') = HasChild;
Dataset.Values('HasChild') = HasChild;
Dataset.Post();
Dataset.Post();
}
}
function AddDefaultValueRecord(Dataset, ID, ParentID, Caption, HasChild){
function AddDefaultValueRecord(Dataset, ID, ParentID, Caption, HasChild){
Dataset.Append();
Dataset.Append();
Dataset.Values('ID') = ID;
Dataset.Values('ID') = ID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('RecordType') = rtcField;
Dataset.Values('RecordType') = rtcField;
Dataset.Values('Caption') = Caption;
Dataset.Values('Caption') = Caption;
Dataset.Values('IsDefaultValue') = true;
Dataset.Values('IsDefaultValue') = true;
Dataset.Values('HasChild') = HasChild;
Dataset.Values('HasChild') = HasChild;
Dataset.Post();
Dataset.Post();
}
}
function AddEnumRecord(Dataset, ID, ParentID, Caption, HasChild,
function AddEnumRecord(Dataset, ID, ParentID, Caption, HasChild,
EnumItemID){
EnumItemID){
Dataset.Append();
Dataset.Append();
Dataset.Values('ID') = ID;
Dataset.Values('ID') = ID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('ParentID') = ParentID;
Dataset.Values('RecordType') = rtcField;
Dataset.Values('RecordType') = rtcField;
Dataset.Values('Caption') = Caption;
Dataset.Values('Caption') = Caption;
Dataset.Values('IsEnum') = true;
Dataset.Values('IsEnum') = true;
Dataset.Values('HasChild') = HasChild;
Dataset.Values('HasChild') = HasChild;
Dataset.Values('EnumItemID') = EnumItemID;
Dataset.Values('EnumItemID') = EnumItemID;
Dataset.Post();
Dataset.Post();
}
}
function GetDestinationCountByDestinationNode(
function GetDestinationCountByDestinationNode(
DestinationNode, DestinationCount){
DestinationNode, DestinationCount){
var BackRelations = DestinationNode.FindChildNode(BackRelationsNodeName);
var BackRelations = DestinationNode.FindChildNode(BackRelationsNodeName);
if (Assigned(BackRelations)){
if (Assigned(BackRelations)){
for (var i = 0; i < BackRelations.Count; i++){
for (var i = 0; i < BackRelations.Count; i++){
DestinationCount = GetDestinationCountByDestinationNode(
DestinationCount = GetDestinationCountByDestinationNode(
BackRelations.Items(i), DestinationCount);
BackRelations.Items(i), DestinationCount);
}
}
}
}
var Column;
var Column;
var DestinationSubNode;
var DestinationSubNode;
var Columns = DestinationNode.FindChildNode(ColumnsNodeName);
var Columns = DestinationNode.FindChildNode(ColumnsNodeName);
if (Assigned(Columns)){
if (Assigned(Columns)){
for (var i = 0; i < Columns.Count; i++){
for (var i = 0; i < Columns.Count; i++){
Column = Columns.Items(i);
Column = Columns.Items(i);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
if (Assigned(DestinationSubNode)){
if (Assigned(DestinationSubNode)){
DestinationCount = GetDestinationCountByDestinationNode(
DestinationCount = GetDestinationCountByDestinationNode(
DestinationSubNode, DestinationCount)
DestinationSubNode, DestinationCount)
}
}
}
}
}
}
DestinationCount++;
DestinationCount++;
return DestinationCount;
return DestinationCount;
}
}
function TranslateDestinationNodeToDataset(Dataset, DestinationNode, ParentID,
function TranslateDestinationNodeToDataset(Dataset, DestinationNode, ParentID,
TranslationType, Nodes, Skip){
TranslationType, Nodes, Skip){
if (!Assigned(Nodes)){
if (!Assigned(Nodes)){
Nodes = new Object();
Nodes = new Object();
}
}
var TableName = DestinationNode.GetAttributeAsStr(NameAttributeName, '');
var TableName = DestinationNode.GetAttributeAsStr(NameAttributeName, '');
if (IsEmptyValue(TableName)){
if (IsEmptyValue(TableName)){
return Nodes;
return Nodes;
}
}
var Table = Services.GetSingleItemByUSI(TableName);
var Table = Services.GetSingleItemByUSI(TableName);
var ForeignKeyFieldName =
var ForeignKeyFieldName =
DestinationNode.GetAttributeAsStr(ForeignKeyFieldAttributeName, '');
DestinationNode.GetAttributeAsStr(ForeignKeyFieldAttributeName, '');
var Caption;
var Caption;
if (IsEmptyValue(ForeignKeyFieldName )){
if (IsEmptyValue(ForeignKeyFieldName )){
Caption = Table.Caption;
Caption = Table.Caption;
} else {
} else {
Caption = GetBackRelationCaption(Table, ForeignKeyFieldName);
Caption = GetBackRelationCaption(Table, ForeignKeyFieldName);
}
}
var DestinationID;
var DestinationID;
if (!Skip){
if (!Skip){
DestinationID = Connector.GenGUID();
DestinationID = Connector.GenGUID();
AddCommonRecord(Dataset, DestinationID, ParentID, rtcTable, Caption);
AddCommonRecord(Dataset, DestinationID, ParentID, rtcTable, Caption);
} else {
} else {
DestinationID = ParentID;
DestinationID = ParentID;
}
}
var BackRelations = DestinationNode.FindChildNode(BackRelationsNodeName);
var BackRelations = DestinationNode.FindChildNode(BackRelationsNodeName);
if (Assigned(BackRelations)){
if (Assigned(BackRelations)){
var BackRelationID = Connector.GenGUID();
var BackRelationID = Connector.GenGUID();
AddCommonRecord(Dataset, BackRelationID, DestinationID,
AddCommonRecord(Dataset, BackRelationID, DestinationID,
rtcBackRelationsGroup, rcBackRelationsGroup);
rtcBackRelationsGroup, rcBackRelationsGroup);
for (var i = 0; i < BackRelations.Count; i++){
for (var i = 0; i < BackRelations.Count; i++){
Nodes = TranslateDestinationNodeToDataset(Dataset,
Nodes = TranslateDestinationNodeToDataset(Dataset,
BackRelations.Items(i), BackRelationID, TranslationType, Nodes);
BackRelations.Items(i), BackRelationID, TranslationType, Nodes);
}
}
if (TranslationType == gtEnumItems){
if (TranslationType == gtEnumItems){
if (!Dataset.Locate('ParentID', BackRelationID)){
if (!Dataset.Locate('ParentID', BackRelationID)){
Dataset.Locate('ID', BackRelationID);
Dataset.Locate('ID', BackRelationID);
Dataset.Delete();
Dataset.Delete();
}
}
}
}
}
}
var Columns = DestinationNode.FindChildNode(ColumnsNodeName);
var Columns = DestinationNode.FindChildNode(ColumnsNodeName);
if (Assigned(Columns)){
if (Assigned(Columns)){
var Column;
var Column;
var DestinationSubNode;
var DestinationSubNode;
var IsPrimary;
var IsPrimary;
var ColumnID;
var ColumnID;
var FieldName;
var FieldName;
var Field;
var Field;
var PostColumn;
var PostColumn;
var Caption;
var Caption;
var DestinationSubNodeExist;
var DestinationSubNodeExist;
var SubTableCode;
var SubTableCode;
var SubTableCaption;
var SubTableCaption;
var Enum;
var Enum;
var EnumItem;
var EnumItem;
var ID;
var ID;
for (var i = 0; i < Columns.Count; i++){
for (var i = 0; i < Columns.Count; i++){
Column = Columns.Items(i);
Column = Columns.Items(i);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
FieldName = Column.GetAttributeAsStr(NameAttributeName, false)
FieldName = Column.GetAttributeAsStr(NameAttributeName, false)
Field = Table.Fields.ItemsByName(FieldName);
Field = Table.Fields.ItemsByName(FieldName);
IsPrimary =
IsPrimary =
Column.GetAttributeAsBool(IsPrimaryAttributeName, false);
Column.GetAttributeAsBool(IsPrimaryAttributeName, false);
IsDefault =
IsDefault =
Column.GetAttributeAsBool(IsDefaultAttributeName, false);
Column.GetAttributeAsBool(IsDefaultAttributeName, false);
IsEnum = (Field.SQLDataType == sdtEnum) && !IsDefault;
IsEnum = (Field.SQLDataType == sdtEnum) && !IsDefault;
PostIsPrimary = IsPrimary && (TranslationType == gtPrimaryKeys);
PostIsPrimary = IsPrimary && (TranslationType == gtPrimaryKeys);
PostIsDefault = IsDefault && (TranslationType == gtDefaultValues);
PostIsDefault = IsDefault && (TranslationType == gtDefaultValues);
PostIsEnum = IsEnum && (TranslationType == gtEnumItems);
PostIsEnum = IsEnum && (TranslationType == gtEnumItems);
PostColumn = PostIsPrimary || PostIsDefault || PostIsEnum;
PostColumn = PostIsPrimary || PostIsDefault || PostIsEnum;
DestinationSubNodeExist = Assigned(DestinationSubNode);
DestinationSubNodeExist = Assigned(DestinationSubNode);
if (!DestinationSubNodeExist && !PostColumn) {
if (!DestinationSubNodeExist && !PostColumn) {
continue;
continue;
}
}
ColumnID = Connector.GenGUID();
ColumnID = Connector.GenGUID();
if (DestinationSubNodeExist){
if (DestinationSubNodeExist){
SubTableCode =
SubTableCode =
DestinationSubNode.GetAttributeAsStr(NameAttributeName, '');
DestinationSubNode.GetAttributeAsStr(NameAttributeName, '');
// TODO
if (!SubTableCode) {
if (!SubTableCode) {
Caption = Field.Caption;
Caption = Field.Caption;
} else {
} else {
SubTableCaption =
SubTableCaption =
Services.GetSingleItemByUSI(SubTableCode).Caption;
Services.GetSingleItemByUSI(SubTableCode).Caption;
Caption = FormatStr(rcForeignKeyColumn, SubTableCaption,
Caption = FormatStr(rcForeignKeyColumn, SubTableCaption,
Field.Caption);
Field.Caption);
}
}
}else {
}else {
Caption = Field.Caption;
Caption = Field.Caption;
}
}
if (PostIsPrimary){
if (PostIsPrimary){
AddPrimaryKeyRecord(Dataset, ColumnID, DestinationID, Caption,
AddPrimaryKeyRecord(Dataset, ColumnID, DestinationID, Caption,
DestinationSubNodeExist);
DestinationSubNodeExist);
} else if (PostIsDefault){
} else if (PostIsDefault){
AddDefaultValueRecord(Dataset, ColumnID, DestinationID,
AddDefaultValueRecord(Dataset, ColumnID, DestinationID,
Caption, DestinationSubNodeExist);
Caption, DestinationSubNodeExist);
} else if (PostIsEnum){
} else if (PostIsEnum){
AddEnumRecord(Dataset, ColumnID, DestinationID, Caption,
AddEnumRecord(Dataset, ColumnID, DestinationID, Caption,
true, null);
true, null);
Enum = Field.Enum;
Enum = Field.Enum;
if (Assigned(Enum)){
if (Assigned(Enum)){
for (var j = 0; j < Enum.Count; j++) {
for (var j = 0; j < Enum.Count; j++) {
EnumItem = Enum.Items(j);
EnumItem = Enum.Items(j);
ID = Connector.GenGUID();
ID = Connector.GenGUID();
AddEnumRecord(Dataset, ID, ColumnID,
AddEnumRecord(Dataset, ID, ColumnID,
EnumItem.Caption, false, EnumItem.ID);
EnumItem.Caption, false, EnumItem.ID);
}
}
}
}
} else {
} else {
AddCommonRecord(Dataset, ColumnID, DestinationID, rtcField,
AddCommonRecord(Dataset, ColumnID, DestinationID, rtcField,
Caption, DestinationSubNodeExist);
Caption, DestinationSubNodeExist);
}
}
if (PostColumn){
if (PostColumn){
Nodes[ColumnID] = Column;
Nodes[ColumnID] = Column;
}
}
if (DestinationSubNodeExist) {
if (DestinationSubNodeExist) {
Nodes = TranslateDestinationNodeToDataset(Dataset,
Nodes = TranslateDestinationNodeToDataset(Dataset,
DestinationSubNode, ColumnID, TranslationType, Nodes, true);
DestinationSubNode, ColumnID, TranslationType, Nodes, true);
if (TranslationType == gtEnumItems){
if (TranslationType == gtEnumItems){
if (!Dataset.Locate('ParentID', ColumnID)){
if (!Dataset.Locate('ParentID', ColumnID)){
Dataset.Locate('ID', ColumnID);
Dataset.Locate('ID', ColumnID);
Dataset.Delete();
Dataset.Delete();
}
}
}
}
}
}
}
}
}
}
if ((TranslationType == gtEnumItems) && !Skip){
if ((TranslationType == gtEnumItems) && !Skip){
if (!Dataset.Locate('ParentID', DestinationID)){
if (!Dataset.Locate('ParentID', DestinationID)){
Dataset.Locate('ID', DestinationID);
Dataset.Locate('ID', DestinationID);
Dataset.Delete();
Dataset.Delete();
}
}
}
}
return Nodes;
return Nodes;
}
}
function GetCanDragOverFromTablesTree(DataTreeGrid, DataGridColumn, RowIDs) {
function GetCanDragOverFromTablesTree(DataTreeGrid, DataGridColumn, RowIDs) {
if (DataTreeGrid.Tag != 'TablesTree') {
if (DataTreeGrid.Tag != 'TablesTree') {
return false;
return false;
}
}
var Result = Assigned(DataGridColumn) && Assigned(DataGridColumn.DataField)
var Result = Assigned(DataGridColumn) && Assigned(DataGridColumn.DataField)
&& RowIDs.Count;
&& RowIDs.Count;
if (Result){
if (Result){
var Dataset = DataTreeGrid.DatasetLink.Dataset;
var Dataset = DataTreeGrid.DatasetLink.Dataset;
DataTreeGrid.BeginUpdate();
DataTreeGrid.BeginUpdate();
Dataset.DisableEvents();
Dataset.DisableEvents();
try {
try {
var OldID = Dataset.Values(mdfnID);
var OldID = Dataset.Values(mdfnID);
for (var i = 0; i < RowIDs.Count; i++) {
for (var i = 0; i < RowIDs.Count; i++) {
Dataset.Locate(mdfnID, RowIDs.Items(i));
Dataset.Locate(mdfnID, RowIDs.Items(i));
if (Dataset.Values(mdfnRecordTypeCode) != rtcField) {
if (Dataset.Values(mdfnRecordTypeCode) != rtcField) {
Result = false;
Result = false;
break;
break;
}
}
}
}
Dataset.Locate(mdfnID, OldID);
Dataset.Locate(mdfnID, OldID);
} finally {
} finally {
Dataset.EnableEvents();
Dataset.EnableEvents();
DataTreeGrid.EndUpdate();
DataTreeGrid.EndUpdate();
}
}
}
}
return Result;
return Result;
}
}
function AddColumnInfoToNode(TreeDataset, ImportItemNode, PathIDs, ParentNode){
function AddColumnInfoToNode(TreeDataset, ImportItemNode, PathIDs, ParentNode){
if (PathIDs.length == 0){
if (PathIDs.length == 0){
return ParentNode;
return ParentNode;
}
}
var RowID = PathIDs.pop();
var RowID = PathIDs.pop();
TreeDataset.Locate(mdfnID, RowID);
TreeDataset.Locate(mdfnID, RowID);
var Node;
var Node;
if (!Assigned(ParentNode)){
if (!Assigned(ParentNode)){
Node = ImportItemNode.GetChildNode(DestinationNodeName);
Node = ImportItemNode.GetChildNode(DestinationNodeName);
Node.SetAttributeAsStr(NameAttributeName,
Node.SetAttributeAsStr(NameAttributeName,
TreeDataset.Values(mdfnTableCode), '');
TreeDataset.Values(mdfnTableCode), '');
} else {
} else {
var RecordType = TreeDataset.Values(mdfnRecordTypeCode);
var RecordType = TreeDataset.Values(mdfnRecordTypeCode);
var TableCode;
var TableCode;
switch (RecordType){
switch (RecordType){
case rtcEmpty:
case rtcEmpty:
Log.Write(lmtError, msgUnsupportedNodeType);
Log.Write(lmtError, msgUnsupportedNodeType);
return null;
return null;
break;
break;
case rtcTable:
case rtcTable:
TableCode = TreeDataset.Values(mdfnTableCode);
TableCode = TreeDataset.Values(mdfnTableCode);
if (ParentNode.Name == BackRelationsNodeName){
if (ParentNode.Name == BackRelationsNodeName){
Node = ParentNode.GetChildNodeByAttributeValue(
Node = ParentNode.GetChildNodeByAttributeValue(
DestinationNodeName, NameAttributeName, TableCode);
DestinationNodeName, NameAttributeName, TableCode);
} else {
} else {
Node = ParentNode.GetChildNode(DestinationNodeName);
Node = ParentNode.GetChildNode(DestinationNodeName);
}
}
Node.SetAttributeAsStr(NameAttributeName,
Node.SetAttributeAsStr(NameAttributeName,
TableCode, '');
TableCode, '');
Node.SetAttributeAsStr(ForeignKeyFieldAttributeName,
Node.SetAttributeAsStr(ForeignKeyFieldAttributeName,
TreeDataset.Values(mdfnFieldName), '');
TreeDataset.Values(mdfnFieldName), '');
break;
break;
case rtcField:
case rtcField:
ParentNode = ParentNode.GetChildNode(ColumnsNodeName);
ParentNode = ParentNode.GetChildNode(ColumnsNodeName);
Node = ParentNode.GetChildNodeByAttributeValue(ItemNodeName,
Node = ParentNode.GetChildNodeByAttributeValue(ItemNodeName,
NameAttributeName, TreeDataset.Values(mdfnFieldName));
NameAttributeName, TreeDataset.Values(mdfnFieldName));
if (PathIDs.length != 0){
if (PathIDs.length != 0){
Node = Node.GetChildNode(DestinationNodeName);
Node = Node.GetChildNode(DestinationNodeName);
var ChildID = PathIDs[PathIDs.length - 1];
var ChildID = PathIDs[PathIDs.length - 1];
TreeDataset.Locate(mdfnID, ChildID);
TreeDataset.Locate(mdfnID, ChildID);
if (IsEmptyStr(Node.GetAttributeAsStr(NameAttributeName, ''))) {
Node.SetAttributeAsStr(NameAttributeName,
Node.SetAttributeAsStr(NameAttributeName,
TreeDataset.Values(mdfnTableCode), '');
TreeDataset.Values(mdfnTableCode), '');
}
}
}
break;
break;
case rtcBackRelationsGroup:
case rtcBackRelationsGroup:
Node = ParentNode.GetChildNode(BackRelationsNodeName);
Node = ParentNode.GetChildNode(BackRelationsNodeName);
break;
break;
}
}
}
}
return AddColumnInfoToNode(TreeDataset, ImportItemNode, PathIDs, Node);
return AddColumnInfoToNode(TreeDataset, ImportItemNode, PathIDs, Node);
}
}
function GetFieldPathIDs(TreeDataset, RowID, PathIDs){
function GetFieldPathIDs(TreeDataset, RowID, PathIDs){
if (!Assigned(PathIDs)){
if (!Assigned(PathIDs)){
PathIDs = new Array();
PathIDs = new Array();
}
}
if (IsEmptyGUID(RowID)){
if (IsEmptyGUID(RowID)){
return PathIDs;
return PathIDs;
}
}
PathIDs.push(RowID);
PathIDs.push(RowID);
if (TreeDataset.Locate(mdfnID, RowID)){
if (TreeDataset.Locate(mdfnID, RowID)){
var ParentID = TreeDataset.Values(mdfnParentID);
var ParentID = TreeDataset.Values(mdfnParentID);
PathIDs = GetFieldPathIDs(TreeDataset, ParentID, PathIDs);
PathIDs = GetFieldPathIDs(TreeDataset, ParentID, PathIDs);
}
}
return PathIDs;
return PathIDs;
}
}
function ClearColumnAttributes(Node){
function ClearColumnAttributes(Node){
Node.SetAttributeAsInt(SourceNameAttributeName, -1, -1);
Node.SetAttributeAsInt(SourceNameAttributeName, -1, -1);
Node.SetAttributeAsBool(IsPrimaryAttributeName, false, false);
Node.SetAttributeAsBool(IsPrimaryAttributeName, false, false);
Node.SetAttributeAsBool(IsDefaultAttributeName, false, false);
Node.SetAttributeAsBool(IsDefaultAttributeName, false, false);
Node.SetAttributeAsInt(TypeAttributeName, -1, -1);
Node.SetAttributeAsInt(TypeAttributeName, -1, -1);
Node.SetAttributeAsStr(ValueAttributeName, '', '');
Node.SetAttributeAsStr(ValueAttributeName, '', '');
var EnumNode = Node.FindChildNode(EnumNodeName);
var EnumNode = Node.FindChildNode(EnumNodeName);
if (Assigned(EnumNode)){
if (Assigned(EnumNode)){
Node.RemoveChildNode(EnumNode);
Node.RemoveChildNode(EnumNode);
}
}
}
}
function GetTableFieldByColumnNode(Node){
function GetTableFieldByColumnNode(Node){
var DestinationNode = Node.ParentNode.ParentNode;
var DestinationNode = Node.ParentNode.ParentNode;
var TableCode = DestinationNode.GetAttributeAsStr(NameAttributeName, '');
var TableCode = DestinationNode.GetAttributeAsStr(NameAttributeName, '');
var Table = Services.GetSingleItemByUSI(TableCode);
var Table = Services.GetSingleItemByUSI(TableCode);
if (!Assigned(Table)){
if (!Assigned(Table)){
return null;
return null;
}
}
var FieldName = Node.GetAttributeAsStr(NameAttributeName, '');
var FieldName = Node.GetAttributeAsStr(NameAttributeName, '');
return Table.Fields.ItemsByName(FieldName);
return Table.Fields.ItemsByName(FieldName);
}
}
function GetTableFieldTypeByColumnNode(Node){
function GetTableFieldTypeByColumnNode(Node){
var Type = -1;
var Type = -1;
var Field = GetTableFieldByColumnNode(Node);
var Field = GetTableFieldByColumnNode(Node);
if (Assigned(Field)){
if (Assigned(Field)){
Type = Field.SQLDataType;
Type = Field.SQLDataType;
}
}
return Type;
return Type;
}
}
function GetIsPrimaryKeysExists(Columns){
function GetIsPrimaryKeysExists(Columns){
var Column;
var Column;
var Exists = false;
var Exists = false;
for (var i = 0; i < Columns.Count ; i++) {
for (var i = 0; i < Columns.Count ; i++) {
Column = Columns.Items(i);
Column = Columns.Items(i);
Exists = Column.GetAttributeAsBool(IsPrimaryAttributeName, false);
Exists = Column.GetAttributeAsBool(IsPrimaryAttributeName, false);
if (Exists){
if (Exists){
break;
break;
}
}
}
}
return Exists;
return Exists;
}
}
function CheckRequiredFieldInDestination(Node, ResultArray){
function CheckRequiredFieldInDestination(Node, ResultArray){
var BackRelations = Node.FindChildNode(BackRelationsNodeName);
var BackRelations = Node.FindChildNode(BackRelationsNodeName);
if (Assigned(BackRelations)){
if (Assigned(BackRelations)){
for (var i = 0; i < BackRelations.Count; i++){
for (var i = 0; i < BackRelations.Count; i++){
CheckRequiredFieldInDestination(BackRelations.Items(i),
CheckRequiredFieldInDestination(BackRelations.Items(i),
ResultArray);
ResultArray);
}
}
}
}
var Columns = Node.FindChildNode(ColumnsNodeName);
var Columns = Node.FindChildNode(ColumnsNodeName);
var NotAssignedFields = new Array();
var NotAssignedFields = new Array();
if (Assigned(Columns)){
if (Assigned(Columns)){
var PrimaryKeysExists = GetIsPrimaryKeysExists(Columns);
var PrimaryKeysExists = GetIsPrimaryKeysExists(Columns);
if (PrimaryKeysExists){
if (PrimaryKeysExists){
var TableCode = Node.GetAttributeAsStr(NameAttributeName, '');
var TableCode = Node.GetAttributeAsStr(NameAttributeName, '');
var Table = Services.GetSingleItemByUSI(TableCode);
var Table = Services.GetSingleItemByUSI(TableCode);
var Fields = Table.Fields;
var Fields = Table.Fields;
var Field;
var Field;
var Column;
var Column;
for (var i = 0; i < Fields.Count ; i++) {
for (var i = 0; i < Fields.Count ; i++) {
Field = Fields.Items(i);
Field = Fields.Items(i);
if (Field.IsRequired && (Field.SQLName != 'ID')){
if (Field.IsRequired && (Field.SQLName != 'ID')){
Column = Columns.FindChildNodeByAttributeValue(ItemNodeName,
Column = Columns.FindChildNodeByAttributeValue(ItemNodeName,
NameAttributeName, Field.SQLName);
NameAttributeName, Field.SQLName);
if (!Assigned(Column)){
if (!Assigned(Column)){
NotAssignedFields.push(Field.SQLName);
NotAssignedFields.push(Field.SQLName);
}
}
}
}
}
}
}
}
var DestinationNode;
var DestinationNode;
for (var i = 0; i < Columns.Count ; i++) {
for (var i = 0; i < Columns.Count ; i++) {
Column = Columns.Items(i);
Column = Columns.Items(i);
DestinationNode = Column.FindChildNode(DestinationNodeName);
DestinationNode = Column.FindChildNode(DestinationNodeName);
if (Assigned(DestinationNode)){
if (Assigned(DestinationNode)){
CheckRequiredFieldInDestination(DestinationNode, ResultArray);
CheckRequiredFieldInDestination(DestinationNode, ResultArray);
}
}
}
}
}
}
if (NotAssignedFields.length > 0){
if (NotAssignedFields.length > 0){
NotAssignedFields.Node = Columns;
NotAssignedFields.Node = Columns;
ResultArray.push(NotAssignedFields);
ResultArray.push(NotAssignedFields);
}
}
}
}
function CheckRequiredFieldInDataflow(XMLStorage){
function CheckRequiredFieldInDataflow(XMLStorage){
var FullResult = new Array();
var FullResult = new Array();
var ItemsNode = XMLStorage.RootNode.GetChildNode(ItemsNodeName);
var ItemsNode = XMLStorage.RootNode.GetChildNode(ItemsNodeName);
var Item;
var Item;
var ItemResult;
var ItemResult;
for (var i = 0; i < ItemsNode.Count; i++) {
for (var i = 0; i < ItemsNode.Count; i++) {
Item = ItemsNode.Items(i).GetChildNode(DestinationNodeName);
Item = ItemsNode.Items(i).GetChildNode(DestinationNodeName);
ItemResult = new Array();
ItemResult = new Array();
CheckRequiredFieldInDestination(Item, ItemResult);
CheckRequiredFieldInDestination(Item, ItemResult);
if (ItemResult.length > 0){
if (ItemResult.length > 0){
ItemResult.Node = Item;
ItemResult.Node = Item;
FullResult.push(ItemResult);
FullResult.push(ItemResult);
}
}
}
}
return FullResult;
return FullResult;
}
}
function GetDataFieldByTableField(DataFields, TableField){
function GetDataFieldByTableField(DataFields, TableField){
var DataField;
var DataField;
switch (TableField.SQLDataType){
switch (TableField.SQLDataType){
case sdtInteger:
case sdtInteger:
DataField = DataFields.CreateIntegerDataField();
DataField = DataFields.CreateIntegerDataField();
break;
break;
case sdtFloat:
case sdtFloat:
DataField = DataFields.CreateFloatDataField();
DataField = DataFields.CreateFloatDataField();
DataField.Size = TableField.SQLSize;
DataField.Size = TableField.SQLSize;
DataField.Precision = TableField.SQLPrecision;
DataField.Precision = TableField.SQLPrecision;
break;
break;
case sdtString:
case sdtString:
case sdtUnicodeString:
case sdtUnicodeString:
DataField = DataFields.CreateStringDataField();
DataField = DataFields.CreateStringDataField();
DataField.TextLength = TableField.SQLSize;
DataField.TextLength = TableField.SQLSize;
break;
break;
case sdtBlob:
case sdtBlob:
DataField = DataFields.CreateStringDataField();
DataField = DataFields.CreateStringDataField();
DataField.TextLength = 10000;
DataField.TextLength = 10000;
break;
break;
case sdtDateTime:
case sdtDateTime:
DataField = DataFields.CreateDateTimeDataField();
DataField = DataFields.CreateDateTimeDataField();
break;
break;
case sdtBoolean:
case sdtBoolean:
DataField = DataFields.CreateBoolDataField();
DataField = DataFields.CreateBoolDataField();
break;
break;
case sdtGUID:
case sdtGUID:
case sdtEnum:
case sdtEnum:
case sdtIdentity:
DataField = DataFields.CreateStringDataField();
DataField = DataFields.CreateStringDataField();
break;
break;
}
}
return DataField;
return DataField;
}
}
function BuildMemoryDatasetByDestinationNode(DestinationNode, MemoryDataset){
function BuildMemoryDatasetByDestinationNode(DestinationNode, MemoryDataset, AddColumns){
if (!Assigned(MemoryDataset)){
if (!Assigned(MemoryDataset)){
MemoryDataset = Services.CreateItem('MemoryDataset');
MemoryDataset = Services.CreateItem('MemoryDataset');
}
}
var TableName = DestinationNode.GetAttributeAsStr(NameAttributeName, '');
var TableName = DestinationNode.GetAttributeAsStr(NameAttributeName, '');
if (IsEmptyValue(TableName)){
if (IsEmptyValue(TableName)){
return MemoryDataset;
return MemoryDataset;
}
}
var Table = Services.GetSingleItemByUSI(TableName);
var Table = Services.GetSingleItemByUSI(TableName);
var BackRelations = DestinationNode.FindChildNode(BackRelationsNodeName);
var BackRelations = DestinationNode.FindChildNode(BackRelationsNodeName);
if (Assigned(BackRelations)){
if (Assigned(BackRelations)){
for (var i = 0; i < BackRelations.Count; i++){
for (var i = 0; i < BackRelations.Count; i++){
MemoryDataset = BuildMemoryDatasetByDestinationNode(
MemoryDataset = BuildMemoryDatasetByDestinationNode(
BackRelations.Items(i), MemoryDataset);
BackRelations.Items(i), MemoryDataset);
}
}
}
}
var Columns = DestinationNode.FindChildNode(ColumnsNodeName);
var Columns = DestinationNode.FindChildNode(ColumnsNodeName);
if (Assigned(Columns)){
if (Assigned(Columns)){
var Column;
var Column;
var DestinationSubNode;
var DestinationSubNode;
var SourceName;
var SourceName;
var FieldName;
var FieldName;
var Field;
var Field;
var TableFieldName;
var TableFieldName;
var TableField;
var TableField;
var FieldsCounter;
var FieldsCounter;
var DataFields = MemoryDataset.DataFields;
var DataFields = MemoryDataset.DataFields;
for (var i = 0; i < Columns.Count; i++){
for (var i = 0; i < Columns.Count; i++){
Column = Columns.Items(i);
Column = Columns.Items(i);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
if (Assigned(DestinationSubNode)){
if (Assigned(DestinationSubNode)){
MemoryDataset = BuildMemoryDatasetByDestinationNode(
MemoryDataset = BuildMemoryDatasetByDestinationNode(
DestinationSubNode, MemoryDataset);
DestinationSubNode, MemoryDataset);
}
}
SourceName = Column.GetAttributeAsStr(SourceNameAttributeName, '');
SourceName = Column.GetAttributeAsStr(SourceNameAttributeName, '');
if (SourceName == ''){
if (SourceName == ''){
continue;
continue;
}
}
TableFieldName = Column.GetAttributeAsStr(NameAttributeName, false);
TableFieldName = Column.GetAttributeAsStr(NameAttributeName, false);
TableField = Table.Fields.ItemsByName(TableFieldName);
TableField = Table.Fields.ItemsByName(TableFieldName);
FieldsCounter = MemoryDataset.Attributes('FieldsCounter') * 1;
FieldsCounter = MemoryDataset.Attributes('FieldsCounter') * 1;
FieldsCounter++;
FieldsCounter++;
MemoryDataset.Attributes('FieldsCounter') = FieldsCounter;
MemoryDataset.Attributes('FieldsCounter') = FieldsCounter;
FieldName = 'Field_' + FieldsCounter;
FieldName = 'Field_' + FieldsCounter;
Column.SetAttributeAsStr(
Column.SetAttributeAsStr(
TempFieldNameAttributeName, FieldName, '');
TempFieldNameAttributeName, FieldName, '');
Field = GetDataFieldByTableField(DataFields, TableField);
Field = GetDataFieldByTableField(DataFields, TableField);
Field.GroupName = SourceName;
Field.GroupName = SourceName;
Field.Name = FieldName;
Field.Name = FieldName;
DataFields.Add(Field);
DataFields.Add(Field);
}
}
if (AddColumns) {
TableField = Table.Fields.ItemsByName('ID');
for (i = 1; i <= AddColumns; i++) {
Field = GetDataFieldByTableField(DataFields, TableField);
Field.GroupName = i;
Field.Name = 'AllFields_' + IntToLetter(i);
DataFields.Add(Field);
}
}
}
}
return MemoryDataset;
return MemoryDataset;
}
}
function GetEnumInfoFromColumn(Column, ColumnObject, Field){
function GetEnumInfoFromColumn(Column, ColumnObject, Field){
ColumnObject.EnumDictionary = new Object();
ColumnObject.EnumDictionary = new Object();
var Enum = Field.Enum;
var Enum = Field.Enum;
if (!Assigned(Enum)){
if (!Assigned(Enum)){
return;
return;
}
}
var EnumItem;
var EnumItem;
var EnumItemNode;
var EnumItemNode;
var EnumItemID;
var EnumItemID;
var Value;
var Value;
var ValueArray;
var ValueArray;
var EnumNode = Column.GetChildNode(EnumNodeName);
var EnumNode = Column.GetChildNode(EnumNodeName);
for (var i = 0; i < EnumNode.Count; i++) {
for (var i = 0; i < EnumNode.Count; i++) {
EnumItemNode = EnumNode.Items(i);
EnumItemNode = EnumNode.Items(i);
EnumItemID = EnumItemNode.GetAttributeAsStr(IDAttributeName, '');
EnumItemID = EnumItemNode.GetAttributeAsStr(IDAttributeName, '');
EnumItem = Enum.ItemsByID(EnumItemID);
EnumItem = Enum.ItemsByID(EnumItemID);
if (!Assigned(EnumItem)){
if (!Assigned(EnumItem)){
continue;
continue;
}
}
Value = EnumItemNode.GetAttributeAsStr(ValueAttributeName, '');
Value = EnumItemNode.GetAttributeAsStr(ValueAttributeName, '');
ValueArray = Value.split(EnumItemValueDelimiter);
ValueArray = Value.split(EnumItemValueDelimiter);
for (var j = 0; j < ValueArray.length; j++) {
for (var j = 0; j < ValueArray.length; j++) {
ColumnObject.EnumDictionary[ValueArray[j].toUpperCase()] = EnumItemID;
ColumnObject.EnumDictionary[ValueArray[j]] = EnumItemID;
}
}
}
}
}
}
function GetDefaultInfoFromColumn(Column, ColumnObject, Field){
function GetDefaultInfoFromColumn(Column, ColumnObject, Field){
ColumnObject.DefaultType =
ColumnObject.DefaultType =
Column.GetAttributeAsInt(TypeAttributeName, -1);
Column.GetAttributeAsInt(TypeAttributeName, -1);
ColumnObject.DefaultIsCorrect = true;
ColumnObject.DefaultIsCorrect = true;
var Value;
var Value;
switch (String(ColumnObject.DefaultType)) {
switch (String(ColumnObject.DefaultType)) {
case dvtValue:
case dvtValue:
break;
break;
case dvtFunction:
case dvtFunction:
ColumnObject.DefaultValue = Column.GetAttributeAsInt(
ColumnObject.DefaultValue = Column.GetAttributeAsInt(
ValueAttributeName, -1);
ValueAttributeName, -1);
ColumnObject.DefaultIsCorrect = (ColumnObject.DefaultValue > 0);
ColumnObject.DefaultIsCorrect = (ColumnObject.DefaultValue > 0);
return;
return;
break;
break;
default:
default:
ColumnObject.DefaultIsCorrect = false;
ColumnObject.DefaultIsCorrect = false;
return;
return;
}
}
switch(Field.SQLDataType){
switch(Field.SQLDataType){
case sdtInteger:
case sdtInteger:
ColumnObject.DefaultValue = Column.GetAttributeAsInt(
ColumnObject.DefaultValue = Column.GetAttributeAsInt(
ValueAttributeName, 0);
ValueAttributeName, 0);
break;
break;
case sdtFloat:
case sdtFloat:
ColumnObject.DefaultValue = Column.GetAttributeAsFloat(
ColumnObject.DefaultValue = Column.GetAttributeAsFloat(
ValueAttributeName, 0);
ValueAttributeName, 0);
break;
break;
case sdtBlob:
case sdtBlob:
case sdtString:
case sdtString:
case sdtUnicodeString:
case sdtUnicodeString:
case sdtGUID:
case sdtGUID:
case sdtEnum:
case sdtEnum:
ColumnObject.DefaultValue = Column.GetAttributeAsStr(
ColumnObject.DefaultValue = Column.GetAttributeAsStr(
ValueAttributeName, '');
ValueAttributeName, '');
break;
break;
case sdtDateTime:
case sdtDateTime:
ColumnObject.DefaultValue = Column.GetAttributeAsDateTime(
ColumnObject.DefaultValue = Column.GetAttributeAsDateTime(
ValueAttributeName, 0);
ValueAttributeName, 0);
break;
break;
case sdtBoolean:
case sdtBoolean:
ColumnObject.DefaultValue = Column.GetAttributeAsBool(
ColumnObject.DefaultValue = Column.GetAttributeAsBool(
ValueAttributeName, false);
ValueAttributeName, false);
break;
break;
default:
default:
ColumnObject.DefaultIsCorrect = false;
ColumnObject.DefaultIsCorrect = false;
break;
break;
}
}
}
}
function GetImportObjectByNode(Destination, Dataset, ImportObjects, UpdateRecords){
function GetImportObjectByNode(Destination, Dataset, ImportObjects, UpdateRecords,
ScriptItem, DataflowID) {
var ImportProgressObject = Connector.Attributes('ImportProgressObject');
var ImportProgressObject = Connector.Attributes('ImportProgressObject');
var ImportObject = new Object();
var ImportObject = new Object();
ImportObject.Updated = 0;
ImportObject.Updated = 0;
ImportObject.Inserted = 0;
ImportObject.Inserted = 0;
ImportObject.PrimaryKeys = new Array();
ImportObject.PrimaryKeys = new Array();
ImportObject.PrimaryKeysIndexes = new Array();
ImportObject.PrimaryKeysIndexes = new Array();
ImportObject.DefaultValues = new Array();
ImportObject.DefaultValues = new Array();
ImportObject.MappedColumns = new Array();
ImportObject.MappedColumns = new Array();
ImportObject.Records = new Object();
ImportObject.Records = new Object();
ImportObject.ErrorList = new Array();
ImportObject.ErrorList = new Array();
Destination.SetAttributeAsInt(TempIndexAttributeName, ImportObjects.length,
Destination.SetAttributeAsInt(TempIndexAttributeName, ImportObjects.length,
-1);
-1);
ImportObject.ImportObjects = ImportObjects;
ImportObject.ImportObjects = ImportObjects;
ImportObject.IsPrimaryObject = !ImportObjects.length;
ImportObject.Position = ImportObjects.length;
ImportObjects.push(ImportObject);
ImportObjects.push(ImportObject);
var ForeignKeyFieldName =
var ForeignKeyFieldName =
Destination.GetAttributeAsStr(ForeignKeyFieldAttributeName, '');
Destination.GetAttributeAsStr(ForeignKeyFieldAttributeName, '');
ImportObject.ForeignKeyFieldName = ForeignKeyFieldName;
ImportObject.ForeignKeyFieldName = ForeignKeyFieldName;
if (!IsEmptyStr(ForeignKeyFieldName)){
if (!IsEmptyStr(ForeignKeyFieldName)){
var ForeignKeyNode = Destination.ParentNode.ParentNode;
var ForeignKeyNode = Destination.ParentNode.ParentNode;
ImportObject.ForeignKeyIndex =
ImportObject.ForeignKeyIndex =
ForeignKeyNode.GetAttributeAsInt(TempIndexAttributeName, -1);
ForeignKeyNode.GetAttributeAsInt(TempIndexAttributeName, -1);
ImportObject.ForeignKeyObject =
ImportObject.ForeignKeyObject =
ImportObject.ImportObjects[ImportObject.ForeignKeyIndex];
ImportObject.ImportObjects[ImportObject.ForeignKeyIndex];
}
}
var TableName = Destination.GetAttributeAsStr(NameAttributeName, '');
var TableName = Destination.GetAttributeAsStr(NameAttributeName, '');
if (IsEmptyValue(TableName)){
if (IsEmptyValue(TableName)){
return ImportObject;
return ImportObject;
}
}
ImportObject.TableName = TableName;
ImportObject.TableName = TableName;
var Table = Services.GetSingleItemByUSI(TableName);
var Table = Services.GetSingleItemByUSI(TableName);
var Columns = Destination.FindChildNode(ColumnsNodeName);
var Columns = Destination.FindChildNode(ColumnsNodeName);
if (!Assigned(Columns)){
if (!Assigned(Columns)){
return ImportObject;
return ImportObject;
}
}
ImportObject.Table = Table;
ImportObject.Table = Table;
var Column;
var Column;
var DestinationSubNode;
var DestinationSubNode;
var TempIndex;
var TempIndex;
var ColumnObject;
var ColumnObject;
var SourceName;
var SourceName;
var FieldName;
var FieldName;
var Field;
var Field;
var DataFieldName;
var DataFieldName;
var DataField;
var DataField;
for (var i = 0; i < Columns.Count; i++){
for (var i = 0; i < Columns.Count; i++){
Column = Columns.Items(i);
Column = Columns.Items(i);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
DestinationSubNode = Column.FindChildNode(DestinationNodeName);
ColumnObject = new Object();
ColumnObject = new Object();
SourceName = Column.GetAttributeAsStr(SourceNameAttributeName, '');
SourceName = Column.GetAttributeAsStr(SourceNameAttributeName, '');
FieldName = Column.GetAttributeAsStr(NameAttributeName, false)
FieldName = Column.GetAttributeAsStr(NameAttributeName, false)
Field = Table.Fields.ItemsByName(FieldName);
Field = Table.Fields.ItemsByName(FieldName);
ColumnObject.Field = Field;
ColumnObject.Field = Field;
ColumnObject.IsLookup = false;
ColumnObject.IsLookup = false;
if (Assigned(DestinationSubNode)){
if (Assigned(DestinationSubNode)){
ImportObjects = ImportDataByDestinationNode(
ImportObjects = ImportDataByDestinationNode(DestinationSubNode, Dataset,
DestinationSubNode, Dataset, ImportObjects, UpdateRecords);
ImportObjects, UpdateRecords, ScriptItem, DataflowID);
if (Assigned(ImportProgressObject) &&
if (Assigned(ImportProgressObject) &&
ImportProgressObject.CancelledByUser){
ImportProgressObject.CancelledByUser){
return;
return;
}
}
if (SourceName != ''){
if (SourceName != ''){
ColumnObject.Index = DestinationSubNode.

GetAttributeAsInt(TempIndexAttributeName, -1);
ColumnObject.IsLookup = true;
if ((ColumnObject.Index == -1)){
ImportObject.ErrorList.push(FormatStr(
msgLookupIsNotDefined, ColumnObject.Field.Caption))
} else if (!(ImportObjects[ColumnObject.Index].Imported)){
ImportObjec