public IHttpActionResult Post(Guid formTemplateId, MetricDTO metricDto) { if (formTemplateId == Guid.Empty) return BadRequest("form template id is empty"); var formTemplate = GetFormTemplate(formTemplateId); if (formTemplate == null) return NotFound(); var metric = Mapper.Map<Metric>(metricDto); metric.FormTemplateId = formTemplateId; try { UnitOfWork.MetricsRepository.InsertOrUpdate(metric); UnitOfWork.MetricsRepository.Save(); MemoryCacher.DeleteStartingWith(CACHE_KEY); return Ok(); } catch (Exception ex) { return InternalServerError(ex); } }
public MetricDTO GetMetrics(int metric_Id) { MetricDTO matric = new MetricDTO(); IList <TagDTO> tag_dto = _tagRespository.SelectAllBy_IsDisable(false); try { Tbl_Metric_DTO tbl_metric_dto = (from metric in _dbcontext.tblMetrics.AsEnumerable() where metric.Id == metric_Id select new Tbl_Metric_DTO { tbl_Metric = metric, tag_dto = SelectAll_Tag_By_TagIDs(Source_Json.Convert_Json_To_Source_Json(metric.Source).Tags), element_dto = SelectAll_Element_By_ElementIDs(Source_Json.Convert_Json_To_Source_Json(metric.Source).Points) }).Single(); matric = MetricDTO.Convert_Table_To_DTO(tbl_metric_dto); } catch (Exception ex) { throw ex; } return(matric); }
public IList <MetricDTO> GetMetricForDropdownListByUserId(string user_id) { List <MetricDTO> metrics = new List <MetricDTO>(); metrics.AddRange(MetricDTO.Convert_List_Table_To_List_DTO(GetMetricBy_UserId(user_id))); return(metrics); }
public IHttpActionResult Put(Guid formTemplateId, Guid id, [FromBody]MetricDTO metricDto) { if (formTemplateId == Guid.Empty) return BadRequest("form template id is empty"); if (id == Guid.Empty) return BadRequest("metric id is empty"); var metric = GetMetric(formTemplateId, id); if (metric == null) NotFound(); try { Mapper.Map(metricDto, metric); UnitOfWork.MetricsRepository.Save(); MemoryCacher.DeleteStartingWith(CACHE_KEY); return Ok(); } catch (Exception ex) { return InternalServerError(ex); } }
public void Add(MetricDTO metric) { _metricRepository.Add(new Entities.Metric() { ApplicationName = metric.ApplicationName, Duration = metric.Duration, MetricName = metric.MetricName }); _metricRepository.UnitOfWork.Commit(); }
public void Save_Metric(MetricDTO metric_dto) { try { _dbcontext.tblMetrics.Add(MetricDTO.Convert_DTO_To_Table(metric_dto)); _dbcontext.SaveChanges(); } catch (Exception ex) { throw ex; } }
public IList <MetricDTO> GetMetricForDropdownList() { List <MetricDTO> metrics = new List <MetricDTO>(); IEnumerable <Tbl_Metric_DTO> tbl_metric_dtos = (from metric in _dbcontext.tblMetrics.AsEnumerable() select new Tbl_Metric_DTO { tbl_Metric = metric }).ToList(); metrics.AddRange(MetricDTO.Convert_List_Table_To_List_DTO(tbl_metric_dtos)); return(metrics); }
public List <MetricDTO> Get_All_Metric_By_User_Id(IEnumerable <string> user_ids) { List <MetricDTO> metrics = new List <MetricDTO>(); IEnumerable <Tbl_Metric_DTO> tbl_metric_dtos = (from metric in _dbcontext.AspNetUserMetrics.AsEnumerable() where user_ids.Contains(metric.User_Id) select new Tbl_Metric_DTO { tbl_Metric = metric.tblMetric }).ToList(); metrics.AddRange(MetricDTO.Convert_List_Table_To_List_DTO(tbl_metric_dtos)); return(metrics); }
public void Update_Metric(MetricDTO metric_dto) { try { tblMetric tbl_Metric = _dbcontext.tblMetrics.Single(metric => metric.Id == metric_dto.Id); MetricDTO.Convert_DTO_To_Table(metric_dto, ref tbl_Metric); _dbcontext.SaveChanges(); } catch (Exception ex) { throw ex; } }
private MetricDTO MapDictionaryToDTO(KeyValuePair <string, Dictionary <string, int> > keyPair) { var dto = new MetricDTO { title = keyPair.Key, value = new ValueDTO() { compose = keyPair.Value.Select(pair => new ComposeValueDTO() { text = pair.Key, count = pair.Value.ToString() }).ToList() } }; return(dto); }
public static MetricUserUIDTO Convert(MetricDTO metric_dto) { MetricUserUIDTO userdataadmin_dto = new MetricUserUIDTO(); try { userdataadmin_dto.Id = metric_dto.Id; userdataadmin_dto.Metric_Name = metric_dto.Metric_Name; userdataadmin_dto.Parent_Id = _parent_Id; } catch (Exception ex) { } return(userdataadmin_dto); }
public void Add(MetricDTO metric) { if (string.IsNullOrEmpty(Setup.GetAPIKey())) { _metricRepository.Add(new Entities.Metric() { ApplicationName = metric.ApplicationName, Duration = metric.Duration, MetricName = metric.MetricName }); _metricRepository.UnitOfWork.Commit(); } else { using (var metricHelper = new MetricHelper(Guid.Parse(Setup.GetAPIKey()))) { metricHelper.Add(new Entities.Metric() { ApplicationName = metric.ApplicationName, Duration = metric.Duration, MetricName = metric.MetricName }); } } }
public IList <MetricDTO> GetMetrics() { List <MetricDTO> matrics = new List <MetricDTO>(); IList <TagDTO> tag_dto = _tagRespository.SelectAllBy_IsDisable(false); try { IEnumerable <Tbl_Metric_DTO> tbl_metric_dtos = (from metric in _dbcontext.tblMetrics.AsEnumerable() select new Tbl_Metric_DTO { tbl_Metric = metric, tag_dto = SelectAll_Tag_By_TagIDs(Source_Json.Convert_Json_To_Source_Json(metric.Source).Tags) }).ToList(); matrics.AddRange(MetricDTO.Convert_List_Table_To_List_DTO(tbl_metric_dtos)); matrics.AddRange(_pre_define_matric); } catch (Exception ex) { throw ex; } return(matrics); }
/// <summary> /// This is use for auto metric geration when the element add in to the structure only for the history point not for the Live point. /// </summary> /// <param name="tbl_Element"></param> public void Save_Metric(IEnumerable <tblElement> tbl_Elements) { try { foreach (var tbl_Element in tbl_Elements) { try { //create matric only for the history points if (tbl_Element.Connector_Live_ID == null) { _dbcontext.tblMetrics.Add(MetricDTO.Convert_DTO_To_Table(tbl_Element.ID, tbl_Element.Element_Name, tbl_Element.Unit_ID, Rollup_Function_Option.SUM)); _dbcontext.tblMetrics.Add(MetricDTO.Convert_DTO_To_Table(tbl_Element.ID, tbl_Element.Element_Name, tbl_Element.Unit_ID, Rollup_Function_Option.MAX)); _dbcontext.tblMetrics.Add(MetricDTO.Convert_DTO_To_Table(tbl_Element.ID, tbl_Element.Element_Name, tbl_Element.Unit_ID, Rollup_Function_Option.MIN)); _dbcontext.tblMetrics.Add(MetricDTO.Convert_DTO_To_Table(tbl_Element.ID, tbl_Element.Element_Name, tbl_Element.Unit_ID, Rollup_Function_Option.AVG)); } } catch (Exception ex) { throw ex; } } _dbcontext.SaveChanges(); } catch (Exception ex) { } }
/// <summary> /// Pre define Metrics are those metrics which automatically created from element tags. In the Point Tagging when tag the elements it will be genrate the metric. SUM Floo1, Max Floor2 and so on. /// Pre define metric does not save in the database /// </summary> /// <returns>List<MetricDTO></returns> public List <MetricDTO> Get_Pre_Define_Metrics() { IList <tblTagElement> list_tag_elements = _dbcontext.tblTagElements.Where(tag_element => tag_element.Is_Deleted == false).ToList(); return(MetricDTO.Convert_Tag_Element_Table_To_DTO(list_tag_elements)); }
public ActionResult Metric_Update([DataSourceRequest] DataSourceRequest request, MetricDTO metric) { try { if (ModelState.IsValid) { _iMetricRepository.Update_Metric(metric); return(Json(new[] { metric }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet)); } else { return(Json(null, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(null, JsonRequestBehavior.AllowGet)); } }