public override string ToString() { var metaTags = MetaTagRepository.ReadMany(MetaTags); var metaTagsString = JsonConvert.SerializeObject(metaTags); return(string.Format("Id: '{0}', Name: '{1}', Description: '{2}', MetaTags: '{3}'", Id, Name, Description, metaTagsString)); }
// GET: MetaTag/Edit/5 public ActionResult Edit(Guid id) { try { var doc = MetaTagRepository.Read(id); return(View(doc)); } catch (Exception e) { return(RedirectToAction("Index")); } }
public ActionResult Delete(Guid id, FormCollection collection) { try { MetaTagRepository.Delete(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(Guid id, FormCollection collection, string name, string description, string dataType) { try { MetaTagRepository.Update(id, name, description, dataType); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Doc/Delete/5 public ActionResult Delete(Guid id) { var model = new DocViewModel(); var doc = DocRepository.Read(id); var docType = DocTypeRepository.Read(Guid.Parse(doc.type)); model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags); model.Type = docType.Name; model.TypeId = docType.Id; model.Values = mapMetaTagsAndDocValue(model.MetaTags, doc); return(View(model)); }
// GET: Doc/FastEntry public ActionResult FastEntry(Guid type) { var model = new FastEntryViewModel(); var docType = DocTypeRepository.Read(type); model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags); model.Type = docType.Name; model.TypeId = type; model.AutoCompletes = new Dictionary <string, List <string> >(); foreach (var metaTag in model.MetaTags.Where(m => m.DataType == "string").ToList()) { model.AutoCompletes.Add(metaTag.Name, DocRepository.GetUniqueStringValuesByMetaTagName(metaTag.Name)); } return(View(model)); }
// GET: Doc/Create public ActionResult Create(Guid type) { var model = new DocViewModel(); var docType = DocTypeRepository.Read(type); model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags); model.Type = docType.Name; model.AutoCompletes = new Dictionary <string, List <string> >(); foreach (var metaTag in model.MetaTags.Where(m => m.DataType == "string").ToList()) { model.AutoCompletes.Add(metaTag.Name, DocRepository.GetUniqueStringValuesByMetaTagName(metaTag.Name)); } model.MostRecentDocuments = DocRepository.GetMostRecentDocumentsForDocType(type, -90); return(View(model)); }
// GET: Doc/Details/5 public ActionResult Details(Guid id, string format) { var model = new DocViewModel(); var doc = DocRepository.Read(id); var docType = DocTypeRepository.Read(Guid.Parse(doc.type)); model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags); model.Id = Guid.Parse(doc.id); model.Type = docType.Name; model.TypeId = docType.Id; model.Values = mapMetaTagsAndDocValue(model.MetaTags, doc); if (format != null && format == "json") { return(Json(model, JsonRequestBehavior.AllowGet)); } return(View(model)); }
private ExpandoObject parseFormToObject() { IDictionary <string, object> doc = new Dictionary <string, object>(); // Entnehme Request Params alle Doc relevanten Parameter (Meta Tags) var docMetaTags = new Dictionary <MetaTag, object>(); foreach (var param in Request.Params.AllKeys) { if (param.Contains("Doc.")) { var paramName = param.Replace("Doc.", ""); MetaTag metaTag; if (paramName != "Id" && paramName != "Type") { metaTag = MetaTagRepository.Read(Guid.Parse(paramName)); doc.Add(metaTag.Name, CastMetaTagValueToDataType(metaTag, Request.Params[param])); } else { doc.Add(paramName, Request.Params[param]); } } } // convert dictionary to object var eo = new ExpandoObject(); var eoColl = (ICollection <KeyValuePair <string, object> >)eo; foreach (var kvp in doc) { eoColl.Add(kvp); } return(eo); }
// GET: Doc/Edit/5 public ActionResult Edit(Guid id) { var model = new DocViewModel(); var doc = DocRepository.Read(id); var docType = DocTypeRepository.Read(Guid.Parse(doc.type)); model.MetaTags = MetaTagRepository.ReadMany(docType.MetaTags); model.Id = Guid.Parse(doc.id); model.Type = docType.Name; model.TypeId = docType.Id; model.Values = mapMetaTagsAndDocValue(model.MetaTags, doc); model.AutoCompletes = new Dictionary <string, List <string> >(); foreach (var metaTag in model.MetaTags.Where(m => m.DataType == "string").ToList()) { model.AutoCompletes.Add(metaTag.Name, DocRepository.GetUniqueStringValuesByMetaTagName(metaTag.Name)); } return(View(model)); }
// GET: Analysis public ActionResult Index(List <string> categories, List <string> facts, string query, string docType, string chartType, string aggFunc, string from, string to) { var model = new AnalysisViewModel(); if (docType == "_all" || docType == null || docType == "") { model.Categories = MetaTagRepository.Index().Where(mt => mt.DataType == "string" || mt.DataType == "datetime" || mt.DataType == "text").ToDictionary <MetaTag, string>(mt => mt.Id.ToString()); model.Facts = MetaTagRepository.Index().Where(mt => mt.DataType == "number").ToDictionary <MetaTag, string>(mt => mt.Id.ToString()); } else { model.Categories = MetaTagRepository.ReadMany(DocTypeRepository.Read(Guid.Parse(docType)).MetaTags) .Where(mt => mt.DataType == "string" || mt.DataType == "datetime" || mt.DataType == "text") .ToDictionary <MetaTag, string>(mt => mt.Id.ToString()); model.Facts = MetaTagRepository.ReadMany(DocTypeRepository.Read(Guid.Parse(docType)).MetaTags) .Where(mt => mt.DataType == "number") .ToDictionary <MetaTag, string>(mt => mt.Id.ToString()); } categories = (categories != null) ? categories : new List <string>(); model.SelectedCategories = categories; model.SelectedFacts = (facts != null)? facts : new List <string>(); if (chartType == null) { chartType = "bar"; } if (aggFunc == null) { aggFunc = "sum"; } model.ChartType = chartType; model.AggFunc = aggFunc; model.Query = query; Guid docTypeGuid; if (Guid.TryParse(docType, out docTypeGuid)) { if (query == null) { query = ""; } if (query.Length > 0) { query += ", "; } query += "type:" + docType; } // from and to date model.From = from; model.To = to; DateTime fromDate; DateTime toDate; int? diffFomDays = null; int? diffToDays = null; if (DateTime.TryParse(from, out fromDate)) { diffFomDays = (fromDate.Date - DateTime.Now.Date).Days; } if (DateTime.TryParse(to, out toDate)) { diffToDays = (toDate.Date - DateTime.Now.Date).Days; } var selectedCategoryNames = new List <string>(); var selectedCategoryTypes = new List <string>(); // in order to save order of selected categories, use iteration foreach (var cat in categories) { var catName = model.Categories.Where(c => c.Value.Id.ToString() == cat).Select(c => c.Value.Name).FirstOrDefault(); var catType = model.Categories.Where(c => c.Value.Id.ToString() == cat).Select(c => c.Value.DataType).FirstOrDefault(); selectedCategoryNames.Add(catName); selectedCategoryTypes.Add(catType); } var selectedFactNames = (facts != null) ? model.Facts.Where(c => facts.Contains(c.Key.ToString())).Select(c => c.Value.Name).ToList <string>() : new List <string>(); var valueList = new List <List <float> >(); var labelList = new List <string>(); var titleList = new List <string>(); // Todo Build Datasets for chartjs markup if (selectedCategoryNames.Count > 1) { var aggs = DocRepository.Aggregate(selectedCategoryNames, selectedFactNames[0], query, aggFunc, diffFomDays, diffToDays); titleList = aggs.Keys.Select(k => k.Split('_')[1]).Distinct().ToList(); var groupKeys = aggs.Keys.Select(k => k.Split('_')[0]).Distinct().ToList(); labelList = groupKeys; foreach (var group in groupKeys) { var valuePairs = aggs.Where(a => a.Key.ToLower().Contains(group.ToLower())).ToList(); var values = new List <float>(); foreach (var title in titleList) { var pair = valuePairs.Where(p => p.Key.ToLower().Contains(title.ToLower())).ToList(); if (pair.Count > 0) { values.Add(pair[0].Value); } else { values.Add(0.0f); } } valueList.Add(values); } } else { foreach (var fact in selectedFactNames) { var aggs = DocRepository.Aggregate(selectedCategoryNames, fact, query, aggFunc, diffFomDays, diffToDays); var values = (selectedCategoryNames.Count > 0 && selectedFactNames.Count > 0) ? aggs.Values.ToList <float>() : new List <float>(); valueList.Add(values); titleList = aggs.Keys.Select(k => k.Replace("_", "")).ToList <string>().Distinct().ToList(); labelList.Add(fact); labelList = (model.AggFunc != "count") ? labelList : new List <string>() { "Anzahl" }; if (model.AggFunc == "count") { break; } } } model.ChartModel = new ChartViewModel() { Height = 400, Categories = titleList.Select(val => { DateTime dateTime; if (DateTime.TryParse(val, out dateTime)) { return(String.Format("{0:yyyy-MM-dd}", dateTime)); } return(val); } ).ToList(), SeriesNames = labelList.Select(val => { DateTime dateTime; if (DateTime.TryParse(val, out dateTime)) { return(String.Format("{0:yyyy-MM-dd}", dateTime)); } return(val); } ).ToList(), Values = valueList, Type = model.ChartType, Title = "", HidePanel = true }; model.DocType = docType; model.DocTypes = DocTypeRepository.Index(); return(View(model)); }
// GET: MetaTag public ActionResult Index() { return(View(MetaTagRepository.Index())); }
// GET: Doc public ActionResult Index(string query, string docType, string from, string to) { var model = new DocIndexViewModel(); model.Query = (query != null) ? query : ""; model.DocType = docType; model.From = from; model.To = to; bool docTypeIsSet = (docType != null && docType.Length > 0); var queryWithFilters = model.Query; queryWithFilters += (docTypeIsSet && queryWithFilters.Length > 0) ? ", " : ""; queryWithFilters += (docTypeIsSet) ? " type:" + docType : ""; DateTime fromDate; DateTime toDate; int? diffFomDays = null; int? diffToDays = null; if (DateTime.TryParse(from, out fromDate)) { diffFomDays = (fromDate - DateTime.Now.Date).Days; } if (DateTime.TryParse(to, out toDate)) { diffToDays = (toDate - DateTime.Now.Date).Days; } var docs = new List <dynamic>(); if (queryWithFilters.Length > 0 || diffFomDays.HasValue || diffToDays.HasValue) { docs = DocRepository.Search(queryWithFilters, diffFomDays, diffToDays, 50); } else { docs = DocRepository.Index(); } var list = new List <DocViewModel>(); foreach (dynamic doc in docs) { var docModel = new DocViewModel(); DocType type = DocTypeRepository.Read(Guid.Parse(doc.type)); docModel.Id = Guid.Parse(doc.id); docModel.Type = type.Name; try { docModel.Name = doc.name; } catch (Exception e) { docModel.Name = ""; } docModel.MetaTags = MetaTagRepository.ReadMany(type.MetaTags); list.Add(docModel); } model.Docs = list; model.DocTypes = DocTypeRepository.Index(); return(View(model)); }