private void Modify(LookupTableDataSet.LookupTableTreesRow row, LookupDTO lookup) { try { if (row.RowState == DataRowState.Deleted) { row.RejectChanges(); } row.LT_PARENT_STRUCT_UID = lookup.ParentID; row.LT_VALUE_SORT_INDEX = lookup.SortIndex; row.LT_VALUE_TEXT = lookup.Text; //row.LT_VALUE_FULL = lookup.DotNotation; row.LT_VALUE_DESC = string.Empty; row.LT_UID = new Guid(Constants.LOOKUP_ENTITY_ID); } catch (Exception ex) { Utility.WriteLog("Error in Modifying a Lookup table tree row =" + ex.Message, EventLogEntryType.Error); } }
/// <summary> /// Add Tree Node to the look up Tree /// </summary> /// <param name="lookup"></param> /// <param name="lookUpSourceCopy"></param> private void AddTreeNode(LookupDTO lookup, LookupTableDataSet lookUpSourceCopy) { try { LookupTableDataSet.LookupTableTreesRow row = lookUpSourceCopy.LookupTableTrees.NewLookupTableTreesRow(); row.LT_STRUCT_UID = lookup.ID; if (lookup.ParentID != Guid.Empty) { row.LT_PARENT_STRUCT_UID = lookup.ParentID; } row.LT_VALUE_SORT_INDEX = lookup.SortIndex; row.LT_VALUE_TEXT = lookup.Text; row.LT_VALUE_FULL = lookup.DotNotation; row.LT_VALUE_DESC = string.Empty; row.LT_UID = new Guid(Constants.LOOKUP_ENTITY_ID); lookUpSourceCopy.LookupTableTrees.AddLookupTableTreesRow(row); } catch (Exception ex) { Utility.WriteLog("Error in Adding a Lookup table tree row =" + ex.Message, EventLogEntryType.Error); } }
/// <summary> /// Maps a single row from a SSIS data to a DTO object /// </summary> /// <param name="row"></param> /// <returns></returns> private LookupDTO MapLookupRow(DataRow row) { try { LookupDTO dto = new LookupDTO(); if (row != null) { dto.ID = row["GeneratedGUID"] != System.DBNull.Value ? new Guid(row["GeneratedGUID"].ToString()) : Guid.Empty; dto.ParentID = row["ParentGeneratedGUID"] != System.DBNull.Value ? new Guid(row["ParentGeneratedGUID"].ToString()) : Guid.Empty; dto.LastLoad = row["LastLoad"] != System.DBNull.Value ? Convert.ToDateTime(row["LastLoad"].ToString()) : default(DateTime); dto.ProcessingDate = row["ProcessingDate"] != System.DBNull.Value ? Convert.ToDateTime(row["ProcessingDate"].ToString()) : default(DateTime); dto.RowLevel = row["RowLevel"] != System.DBNull.Value ? Convert.ToInt32(row["RowLevel"].ToString()) : 0; dto.SortIndex = row["SortIndex"] != System.DBNull.Value ? Convert.ToInt32(row["SortIndex"].ToString()) : 0; dto.Text = row["Item"] != System.DBNull.Value ? row["Item"].ToString() : string.Empty; dto.DotNotation = row["DotNotation"] != System.DBNull.Value ? row["DotNotation"].ToString() : string.Empty; dto.COID = row["COID"] != System.DBNull.Value ? row["COID"].ToString() : string.Empty; } return dto; } catch (Exception ex) { Utility.WriteLog("Error in Mapping DTO for a Lookup table tree row =" + ex.Message, EventLogEntryType.Error); } return new LookupDTO(); }
/// <summary> /// Add Child node to the lookup Tree /// </summary> /// <param name="lookup"></param> /// <param name="lookUpSourceCopy"></param> private void AddChildNode(LookupDTO lookup, LookupTableDataSet lookUpSourceCopy) { try { //If its parent node is present for the node if (lookUpSourceCopy.LookupTableTrees.Any(t => t.Field<Guid?>("LT_STRUCT_UID") == (Guid?)lookup.ParentID) == true) { // Add or modify depending on whether the node itself already exists if (lookUpSourceCopy.LookupTableTrees.Any(t => t.Field<Guid?>("LT_STRUCT_UID") == (Guid?)lookup.ID) == false) { AddTreeNode(lookup, lookUpSourceCopy); } else { LookupTableDataSet.LookupTableTreesRow row = lookUpSourceCopy.LookupTableTrees.First(t => t.Field<Guid?>("LT_STRUCT_UID") == (Guid?)lookup.ID); Modify(row, lookup); } } //Else add up the parent node else { // If aprent node does not already exist in the lookup Tree if (lookUpSourceCopy.LookupTableTrees.Any(t => t.Field<Guid?>("LT_STRUCT_UID") == (Guid?)lookup.ParentID) == false) { // Add Parent Node if (lookup.ParentNode != null) { AddTreeNode(lookup.ParentNode, lookUpSourceCopy); } } else { //Else modify the Parent Node if (lookup.ParentNode != null) { LookupTableDataSet.LookupTableTreesRow row = lookUpSourceCopy.LookupTableTrees.First(t => t.Field<Guid?>("LT_STRUCT_UID") == (Guid?)lookup.ParentID); Modify(row, lookup.ParentNode); } } } } catch (Exception ex) { Utility.WriteLog("Error in Adding a Lookup table tree row =" + ex.Message, EventLogEntryType.Error); } }