コード例 #1
0
ファイル: ElementDTO.cs プロジェクト: leodeveloper/Analytics
        /// <summary>
        ///
        /// </summary>
        /// <param name="objElementDTO"></param>
        /// <returns></returns>
        public static tblElement ConvertDTOToTable(ElementDTO objElementDTO)
        {
            tblElement objElementTable = new tblElement();

            if (objElementDTO.Connector_History != null)
            {
                objElementTable.Connector_History_ID = objElementDTO.Connector_History.ConnectionID;
            }
            if (objElementDTO.Connector_Live != null)
            {
                objElementTable.Connector_Live_ID = objElementDTO.Connector_Live.ConnectionID;
            }

            objElementTable.Element_Name     = objElementDTO.Element_Name;
            objElementTable.Element_Tag_Type = objElementDTO.Element_Tag_Type.ToString();
            //   objElementTable.tblTagElements = TagElementDTO.ConvertDTOToTbl(objElementDTO.TagElements);

            objElementTable.Source_Element_Name_History = objElementDTO.Source_Element_Name_History;
            objElementTable.Source_Element_Name_Live    = objElementDTO.Source_Element_Name_Live;

            objElementTable.Is_Disabled = objElementDTO.Is_Disabled;

            objElementTable.Parent_Element_ID = objElementDTO.Parent_Element_ID;

            return(objElementTable);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="TagElementTbl"></param>
        /// <returns></returns>
        public static TagElementDTO ConvertTableToDTO(tblTagElement TagElementTbl)
        {
            TagElementDTO objTagElementDTO = new TagElementDTO();

            objTagElementDTO.ID       = TagElementTbl.ID;
            objTagElementDTO.TagValue = TagElementTbl.Value;
            objTagElementDTO.Tag      = TagDTO.ConvertTableToDTO(TagElementTbl.tblTag);
            objTagElementDTO.Element  = ElementDTO.ConvertTableToDTO(TagElementTbl.tblElement);
            return(objTagElementDTO);
        }
コード例 #3
0
ファイル: ElementDTO.cs プロジェクト: leodeveloper/Analytics
        /// <summary>
        ///
        /// </summary>
        /// <param name="objElementDTO"></param>
        /// <returns></returns>
        public static tblElement ConvertDTOToTable(ElementDTO objElementDTO, ref tblElement objElementTable)
        {
            if (objElementTable == null)
            {
                objElementTable = new tblElement();
            }

            if (objElementDTO.Connector_History != null)
            {
                objElementTable.Connector_History_ID = objElementDTO.Connector_History.ConnectionID;
            }
            if (objElementDTO.Connector_Live != null)
            {
                objElementTable.Connector_Live_ID = objElementDTO.Connector_Live.ConnectionID;
            }


            objElementTable.Element_Name     = objElementDTO.Element_Name;
            objElementTable.Data_Type        = objElementDTO.Data_Type.ToString();
            objElementTable.Element_Tag_Type = objElementDTO.Element_Tag_Type.ToString();


            ICollection <tblTagElement> temp_tbl_tag_collection = objElementTable.tblTagElements;


            TagElementDTO.ConvertDTOToTbl(objElementDTO.Tags, ref temp_tbl_tag_collection, objElementDTO.ID);

            objElementTable.Source_Element_Name_History = objElementDTO.Source_Element_Name_History;
            objElementTable.Source_Element_Name_Live    = objElementDTO.Source_Element_Name_Live;

            objElementTable.Is_Disabled = objElementDTO.Is_Disabled;

            objElementTable.Parent_Element_ID = objElementDTO.Parent_Element_ID;

            if (objElementDTO.Unit.ID > 0)
            {
                objElementTable.Unit_ID = objElementDTO.Unit.ID;
            }

            objElementTable.Freq      = objElementDTO.Freq;
            objElementTable.Freq_Unit = objElementDTO.Freq_Unit.ToString();

            objElementTable.Recorded_Freq_Unit = objElementDTO.Recorded_Freq_Unit.ToString();
            objElementTable.Recorded_Freq      = objElementDTO.Recorded_Freq;

            objElementTable.Max_Value   = objElementDTO.Max_Value;
            objElementTable.Min_Value   = objElementDTO.Min_Value;
            objElementTable.IsRead_Only = objElementDTO.IsRead_Only;

            return(objElementTable);
        }
コード例 #4
0
        /// <summary>
        /// Element realted with tags
        /// </summary>
        /// <param name="tbl_Metric"></param>
        /// <param name="tag_dto"></param>
        /// <returns></returns>
        public static ChartRawDataDTO Convert(MetricDTO metric_dto, ElementDTO tag_element_dto)
        {
            ChartRawDataDTO chart_raw_data_dto = new ChartRawDataDTO();

            chart_raw_data_dto.Metric_ID    = metric_dto.Id;
            chart_raw_data_dto.Metric       = metric_dto.Metric_Name;
            chart_raw_data_dto.Metric_Unit  = metric_dto.Unit.Unit_Name;
            chart_raw_data_dto.Tag          = Helper.ConvertIEnumerableToString(metric_dto.Tags.Select(tag => tag.Tag_Type_Value), ",");
            chart_raw_data_dto.Element_Id   = tag_element_dto.ID;
            chart_raw_data_dto.Element_Name = tag_element_dto.Element_Name;
            chart_raw_data_dto.Element_Unit = tag_element_dto.Unit.Unit_Name;

            return(chart_raw_data_dto);
        }
コード例 #5
0
ファイル: ElementDTO.cs プロジェクト: leodeveloper/Analytics
        /// <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);
        }