/// <summary> /// Convert Database Table to Data Transform Object /// </summary> /// <param name="objTblPoint"></param> objtblPoint is the list of table name, files name , API links, this is the actually data located /// <param name="objExistingConnectionNameDTO"></param>Connection inform where the tblPoints belongs /// <param name="structuredElementList"></param> list of structured element which is already structured into our database /// <returns></returns> public static DiscoveryElementDTO ConvertTableToDTO(tblPoint objTblPoint, ExistingConnectionNameDTO objExistingConnectionNameDTO, IList <ElementDTO> structuredElementList) { return(new DiscoveryElementDTO { ElementSourceID = objTblPoint.TableRefKey, ElementSourceName = objTblPoint.PointName, ConnectionInfo = objExistingConnectionNameDTO, Structured = structuredElementList.Any(element_list => element_list.Source_Element_Name_History == objTblPoint.PointName || element_list.Source_Element_Name_Live == objTblPoint.PointName) }); }
private static DiscoveryPoint_DTO Convert_Connection_To_Discovery_Point(ExistingConnectionNameDTO ExistingConnectionNameDTO) => new DiscoveryPoint_DTO { ElementSourceID = ExistingConnectionNameDTO.ConnectionName, ElementSourceName = ExistingConnectionNameDTO.ConnectionName, ID = ExistingConnectionNameDTO.ConnectionID, Row_Type = DiscoverPoint_Type.Connection, Structured = false, hasChildren = true, Parent_ID = null // this will be the row that why parent ID is null };
public static ExistingConnectionNameDTO ConvertTableToDTO(ConnectorDTO _dtoConnector) { ExistingConnectionNameDTO _dtoExistingConnection = new ExistingConnectionNameDTO(); _dtoExistingConnection.ConnectionID = _dtoConnector.ConnectionID; _dtoExistingConnection.ConnectionName = _dtoConnector.ConnectionName; _dtoExistingConnection.DataConnectorType = (DataSouceConnectionType)Enums.TryParse(typeof(DataSouceConnectionType), _dtoConnector.DataConnectorType.ToString()); _dtoExistingConnection.IsActive = _dtoConnector.IsActive; return(_dtoExistingConnection); }
public static UnStructureExisitingConnectionElements ConvertTableToDTO(ExistingConnectionNameDTO objExistingConnector) { UnStructureExisitingConnectionElements dto = new UnStructureExisitingConnectionElements(); dto.ConnectionID = objExistingConnector.ConnectionID; dto.ConnectionName = objExistingConnector.ConnectionName; dto.DataConnectorType = objExistingConnector.DataConnectorType; dto.UnStructureElements = null; return(dto); }
/// <summary> /// /// </summary> /// <param name="objElementTable"></param> /// <returns></returns> public static ElementDTO ConvertTableToDTO(tblElement objElementTable) { ElementDTO objElementDTO = new ElementDTO(); objElementDTO.ID = objElementTable.ID; if (objElementTable.tblConnector != null) { //objElementDTO.Connector_Live = ConnectorDTO.ConvertTableToDTO(objElementTable.tblConnector); objElementDTO.ConnectionInfo = ExistingConnectionNameDTO.ConvertTableToDTO(objElementTable.tblConnector); } else if (objElementTable.tblConnector1 != null) { //objElementDTO.Connector_History = ConnectorDTO.ConvertTableToDTO(objElementTable.tblConnector1); objElementDTO.ConnectionInfo = ExistingConnectionNameDTO.ConvertTableToDTO(objElementTable.tblConnector1); } objElementDTO.Element_Name = objElementTable.Element_Name; objElementDTO.Source_Element_Name_History = objElementTable.Source_Element_Name_History; objElementDTO.Source_Element_Name_Live = objElementTable.Source_Element_Name_Live; objElementDTO.Is_Disabled = objElementTable.Is_Disabled; //IT does not required for the presentation layer //objElementDTO.TagElements = TagElementBaseDTO.ConvertTableToDTO(objElementTable.tblTagElements); objElementDTO.Tags = TagDTO.ConvertTableToDTO(objElementTable.tblTagElements); objElementDTO.Parent_Element_ID = objElementTable.Parent_Element_ID; if (objElementTable.tblElement1 != null) { objElementDTO.HasChildren = true; } // objElementDTO.Parent_Element = ConvertTableListToDTOList(objElementTable.tblElement1); objElementDTO.Element_Tag_Type = (TagType)Enums.TryParse(typeof(TagType), objElementTable.Element_Tag_Type.ToString()); // (TagType)Enum.Parse(typeof(TagType), objElementTable.Element_Tag_Type); //TagType.Site objElementDTO.Unit = Unit_Of_Measurement_DTO.Convert_Table_To_DTO(objElementTable.tblUnit); objElementDTO.Freq = objElementTable.Freq; objElementDTO.Recorded_Freq = objElementTable.Recorded_Freq; if (objElementTable.Freq_Unit != null) { if (Enum.IsDefined(typeof(Time_Unit), objElementTable.Freq_Unit)) { objElementDTO.Freq_Unit = (Time_Unit)Enum.Parse(typeof(Time_Unit), objElementTable.Freq_Unit); } } if (objElementTable.Recorded_Freq_Unit != null) { if (Enum.IsDefined(typeof(Time_Unit), objElementTable.Recorded_Freq_Unit)) { objElementDTO.Recorded_Freq_Unit = (Time_Unit)Enum.Parse(typeof(Time_Unit), objElementTable.Recorded_Freq_Unit); } } if (objElementTable.Data_Type != null) { if (Enum.IsDefined(typeof(Data_Formate), objElementTable.Data_Type)) { objElementDTO.Data_Type = (Data_Formate)Enum.Parse(typeof(Data_Formate), objElementTable.Data_Type); } } if (objElementTable.Value_Type != null) { if (Enum.IsDefined(typeof(DataValueType), objElementTable.Value_Type)) { objElementDTO.Value_Type = (DataValueType)Enum.Parse(typeof(DataValueType), objElementTable.Value_Type); } } objElementDTO.Min_Value = objElementTable.Min_Value; objElementDTO.Max_Value = objElementTable.Max_Value; objElementDTO.IsRead_Only = objElementTable.IsRead_Only; return(objElementDTO); }
public static DiscoveryPoint_DTO Get_Connection_Row(ExistingConnectionNameDTO ExistingConnectionNameDTO) { return(Convert_Connection_To_Discovery_Point(ExistingConnectionNameDTO)); }
/// <summary> /// This conversion is for live points /// </summary> /// <param name="objLivePoints"></param> /// <param name="objExistingConnectionNameDTO"></param> /// <param name="structuredElementList"></param> /// <returns></returns> public static ICollection <DiscoveryElementDTO> ConvertTableToDTO(IEnumerable <LivePointModel> objLivePoints, ExistingConnectionNameDTO objExistingConnectionNameDTO, IList <ElementDTO> structuredElementList) { ICollection <DiscoveryElementDTO> listDiscoveryElementDTO = new HashSet <DiscoveryElementDTO>(); foreach (LivePointModel objLivePoint in objLivePoints) { listDiscoveryElementDTO.Add(ConvertTableToDTO(objLivePoint, objExistingConnectionNameDTO, structuredElementList)); } return(listDiscoveryElementDTO); }
/// <summary> /// Convert List Database Table to list Data Transform Object /// </summary> /// <param name="objTblPoint"></param> objtblPoint is the list of table name, files name , API links, this is the actually data located /// <param name="objExistingConnectionNameDTO"></param>Connection inform where the tblPoints belongs /// <param name="structuredElementList"></param> list of structured element which is already structured into our database /// <returns></returns> public static IList <DiscoveryPoint_DTO> ConvertTableToDTO(IEnumerable <tblPoint> objTblPoints, ExistingConnectionNameDTO ExistingConnectionNameDTO, IList <ElementDTO> structuredElementList) { IList <DiscoveryPoint_DTO> list_discovery_point_dto = new List <DiscoveryPoint_DTO>(); //First row would always be the connection info //list_discovery_point_dto.Add(DiscoveryPoint_DTO_Conversion_Base.Get_Connection_Row(ExistingConnectionNameDTO)); foreach (var objTblPoint in objTblPoints) { list_discovery_point_dto.Add(Convert_Point_To_Discovery_Point(objTblPoint, ExistingConnectionNameDTO.ConnectionID, structuredElementList)); } return(list_discovery_point_dto); }