private void ArticleMapItems(ImportItemsArgs args, OutputMap outputMap, DataRow row, ItemDto parentItem, TableInfo tableInfo, bool isSpecialEvent) { var dataTable = tableInfo.Datatable; var currentRow = tableInfo.CurrentRow; // Show in Main var rootItem = new ID(Constants.MainSiteArticleRootId); if (isSpecialEvent) { rootItem = new ID(Constants.MainSiteEventRootId); } args.CurrentImportMallIdTemp = string.Empty; ImportMapEachRow(row, outputMap, args, rootItem, parentItem, tableInfo, isSpecialEvent); // Show in Malls var showInMallValues = dataTable.Rows[currentRow][EventInputField.ShowInMalls.ToString()].ToString(); var mallItems = CreateAndGetMalls(showInMallValues, args); foreach (MallItem mallItem in mallItems) { var rootArticleItem = mallItem.ArticleRootID; if (isSpecialEvent) { rootArticleItem = mallItem.EventRootID; } args.CurrentImportMallIdTemp = mallItem.MallID.ToString(); ImportMapEachRow(row, outputMap, args, rootArticleItem, parentItem, tableInfo, isSpecialEvent); } }
private void ImportMapItems(ImportItemsArgs args, DataTable dataTable, OutputMap outputMap, ItemDto parentItem, bool rootLevel) { var groupedTable = dataTable.GroupBy(outputMap.Fields.Select(f => f.SourceColumn).ToArray()); for (int i = 0; i < groupedTable.Rows.Count; i++) { var row = groupedTable.Rows[i]; if (rootLevel || Convert.ToString(row[outputMap.ParentMap.NameInputField]) == parentItem.Name) { var createdItem = CreateItem(row, outputMap); createdItem.Parent = parentItem; parentItem.Children.Add(createdItem); if (outputMap.ChildMaps != null && outputMap.ChildMaps.Any()) { foreach (var childMap in outputMap.ChildMaps) { ImportMapItems(args, dataTable, childMap, createdItem, false); } } } } }
public static SocketInformation Construct(FieldInfo field, OutputMap socket) { var socketInformation = new SocketInformation { Type = socket.ConnectionType.Name }; return(socketInformation); }
private void ImportMapItems(ImportItemsArgs args, DataTable dataTable, OutputMap outputMap, ItemDto parentItem, bool rootLevel, string parent = "") { switch (args.ImportOptions.DataStructureType) { case DataStructureType.Tabular: var groupedTable = dataTable.GroupBy(outputMap.Fields.Select(f => f.SourceColumn).ToArray()); for (int i = 0; i < groupedTable.Rows.Count; i++) { var row = groupedTable.Rows[i]; if (rootLevel || Convert.ToString(row[outputMap.ParentMap.NameInputField]) == parentItem.Name) { var createdItem = CreateItem(row, outputMap); createdItem.Parent = parentItem; parentItem.Children.Add(createdItem); if (outputMap.ChildMaps != null && outputMap.ChildMaps.Any()) { foreach (var childMap in outputMap.ChildMaps) { ImportMapItems(args, dataTable, childMap, createdItem, false); } } } } break; case DataStructureType.Hierarchichal: var currentleveltable = dataTable.Select("father='" + parent + "'"); foreach (var row in currentleveltable) { for (int i = 0; i < args.Map.OutputMaps.Count; i++) { var map = args.Map.OutputMaps[i]; var reg = OutputMapRegexs[i]; if (reg.IsMatch(row["Path"].ToString())) { var createdItem = CreateItem(row, map); createdItem.Parent = parentItem; parentItem.Children.Add(createdItem); ImportMapItems(args, dataTable, map, createdItem, false, row["ID"].ToString()); break; } } } break; default: break; } }
private void BlogMapItems(ImportItemsArgs args, OutputMap outputMap, DataRow row, ItemDto parentItem, TableInfo tableInfo) { // Show in Main var rootItem = new ID(Constants.MainSiteBlogRootId); ImportMapEachRow(row, outputMap, args, rootItem, parentItem, tableInfo); //Show in Malls foreach (MallItem mallItem in args.MallItems) { ImportMapEachRow(row, outputMap, args, mallItem.BlogRootID, parentItem, tableInfo); } }
private ItemDto CreateItemDto(DataRow dataRow, OutputMap outputMap, ImportItemsArgs args, DataTable dataTable, int currentRow) { var item = InitialItem(outputMap.TemplateId, dataRow, args.ContentType); if (item != null) { for (int i = 0; i < outputMap.Fields.Count; i++) { var mapFieldName = outputMap.Fields[i].TargetFieldName; var fieldValue = GetFieldValue(dataRow, outputMap, args, dataTable, currentRow, i, mapFieldName); item.Fields.Add(mapFieldName, fieldValue); } } return(item); }
private void EventMapItems(ImportItemsArgs args, OutputMap outputMap, DataRow row, ItemDto parentItem, TableInfo tableInfo) { // Show in Main var rootItem = new ID(Constants.MainSiteEventRootId); ImportMapEachRow(row, outputMap, args, rootItem, parentItem, tableInfo); //Show in Malls var showInMallValues = tableInfo.Datatable.Rows[tableInfo.CurrentRow][EventInputField.ShowInMalls.ToString()].ToString(); var mallItems = CreateAndGetMalls(showInMallValues, args); foreach (MallItem mallItem in mallItems) { ImportMapEachRow(row, outputMap, args, mallItem.EventRootID, parentItem, tableInfo); } }
private void ImportMapItems(ImportItemsArgs args, DataTable dataTable, OutputMap outputMap, ItemDto parentItem, bool rootLevel, bool isSpecialEvent) { var groupedTable = dataTable.GroupBy(outputMap.Fields.Select(f => f.SourceColumn).ToArray()); for (int i = 0; i < groupedTable.Rows.Count; i++) { var row = groupedTable.Rows[i]; if (rootLevel || System.Convert.ToString(row[outputMap.ParentMap.NameInputField]) == parentItem.Name) { ID rootItem = ID.Null; var tableInfo = new TableInfo() { CurrentRow = i, Datatable = dataTable }; if (args.ContentType == ContentType.Banner.ToString()) { BannerMapItems(args, outputMap, row, parentItem, tableInfo); } else if (args.ContentType == ContentType.Event.ToString()) { EventMapItems(args, outputMap, row, parentItem, tableInfo); } else if (args.ContentType == ContentType.Article.ToString()) { ArticleMapItems(args, outputMap, row, parentItem, tableInfo, isSpecialEvent); } else if (args.ContentType == ContentType.Store.ToString()) { var rowMallName = dataTable.Rows[i][StoreInputField.Mall.ToString()].ToString(); rootItem = args.MallItems.Where(x => x.MallName.Equals(rowMallName, StringComparison.OrdinalIgnoreCase)).Select(x => x.StoreRootID).FirstOrDefault(); ImportMapEachRow(row, outputMap, args, rootItem, parentItem, tableInfo); } else if (args.ContentType == ContentType.Blog.ToString()) { BlogMapItems(args, outputMap, row, parentItem, tableInfo); } else { ImportMapEachRow(row, outputMap, args, rootItem, parentItem, tableInfo); } } } }
private ItemDto CreateItem(DataRow dataRow, OutputMap outputMap) { var itemName = Convert.ToString(dataRow[outputMap.NameInputField]); var item = new ItemDto(itemName) { TemplateId = outputMap.TemplateId }; for (int i = 0; i < outputMap.Fields.Count; i++) { var mapFieldName = outputMap.Fields[i].TargetFieldName; if (!string.IsNullOrEmpty(mapFieldName)) { var fieldValue = dataRow[outputMap.Fields[i].SourceColumn].ToString(); item.Fields.Add(mapFieldName, fieldValue); } } return(item); }
private void ImportMapEachRow(DataRow dataRow, OutputMap outputMap, ImportItemsArgs args, ID rootItem, ItemDto parentItem, TableInfo tableInfo, bool isSpecialEvent = false) { var createdItem = CreateItemDto(dataRow, outputMap, args, tableInfo.Datatable, tableInfo.CurrentRow); if (createdItem != null) { createdItem.ParentRootId = rootItem; createdItem.Parent = parentItem; parentItem.Children.Add(createdItem); if (outputMap.ChildMaps != null && outputMap.ChildMaps.Any()) { foreach (var childMap in outputMap.ChildMaps) { ImportMapItems(args, tableInfo.Datatable, childMap, createdItem, false, isSpecialEvent); } } } }
private string GetFieldValue(DataRow dataRow, OutputMap outputMap, ImportItemsArgs args, DataTable dataTable, int currentRow, int fieldIndex, string mapFieldName) { string fieldValue = string.Empty; if (!string.IsNullOrEmpty(mapFieldName)) { fieldValue = dataRow[outputMap.Fields[fieldIndex].SourceColumn].ToString(); if ((args.ContentType == ContentType.Event.ToString() && mapFieldName != EventOutputField.Description.GetDescription()) || (args.ContentType == ContentType.Article.ToString() && mapFieldName != ArticleOutputField.Description.GetDescription()) || (args.ContentType == ContentType.Blog.ToString() && mapFieldName != BlogOutputField.Body.ToString())) { fieldValue = Utils.RemoveHTML(fieldValue); } if (args.ContentType == ContentType.Store.ToString()) { fieldValue = GetStoreFieldValue(args, dataTable, currentRow, mapFieldName, fieldValue); } else if (args.ContentType == ContentType.Banner.ToString()) { fieldValue = GetBannerFieldValue(args, mapFieldName, fieldValue); } else if (args.ContentType == ContentType.Event.ToString()) { fieldValue = GetEventFieldValue(args, mapFieldName, fieldValue); } else if (args.ContentType == ContentType.Article.ToString()) { fieldValue = GetArticleFieldValue(args, mapFieldName, fieldValue); } else if (args.ContentType == ContentType.Blog.ToString()) { fieldValue = GetBlogFieldValue(args, mapFieldName, fieldValue); } } return(fieldValue); }