public ActionResult InfoDocument(int OID) { Doc docDetail = DocRepository.SelDocObject(new Doc { OID = OID }); if (docDetail.Doc_Lib_Lev1_OID != null) { docDetail.Doc_Lib_Lev1_KorNm = LibraryRepository.SelLibraryObject(new Library { OID = docDetail.Doc_Lib_Lev1_OID }).KorNm; } if (docDetail.Doc_Lib_Lev2_OID != null) { docDetail.Doc_Lib_Lev2_KorNm = LibraryRepository.SelLibraryObject(new Library { OID = docDetail.Doc_Lib_Lev2_OID }).KorNm; } if (docDetail.Doc_Lib_Lev3_OID != null) { docDetail.Doc_Lib_Lev3_KorNm = LibraryRepository.SelLibraryObject(new Library { OID = docDetail.Doc_Lib_Lev3_OID }).KorNm; } ViewBag.docDetail = docDetail; ViewBag.Status = BPolicyRepository.SelBPolicy(new BPolicy { Type = DocumentContant.TYPE_DOCUMENT }); return(View()); }
public ActionResult Edit(Guid id, FormCollection collection) { try { DocRepository.Update(parseFormToObject()); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(Guid id, FormCollection collection) { try { DocRepository.Delete(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public DocumentService() { var currentUser = Membership.GetUser(); if (string.IsNullOrEmpty(currentUser?.UserName)) { throw new Exception("Authorization Error"); } docRepository = DocRepositoryContext.GetInstance().DocRepositories .GetOrAdd(currentUser.UserName, (key) => new DocRepository()); }
// 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)); }
public ActionResult Create(FormCollection collection, Guid type, int anzahl) { try { for (int i = 0; i < anzahl; i++) { DocRepository.Create(type, parseFormToObject()); } return(RedirectToAction("Index")); } catch (Exception e) { return(View()); } }
public DocFormDataSet(IDataContext dataContext, IEnumerable <Guid> docs, BizControl form, Guid userId) { DocList = new List <Guid>(docs); Form = form; if (dataContext == null) { DataContext = new DataContext(); _ownDataContext = true; } else { DataContext = dataContext; } FormRepo = new FormRepository(DataContext, userId); DocRepo = new DocRepository(DataContext, userId); }
// 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)); }
public void DocReportTest() { var docDefId = Guid.Parse("{4455B9CB-2564-4A92-A295-E3C0BEDB7AC2}"); using (var dataContext = new DataContext()) { var docRepo = new DocRepository(dataContext, _userId); Doc templateDoc = docRepo.New(docDefId); int pageCount = 0; List <Guid> docIds = docRepo.List(out pageCount, docDefId, 1, 0); List <Doc> docs = docIds.Select(docRepo.LoadById).ToList(); var report = new ExcelDocListReport("Тестовое название отчета", docs, templateDoc); report.SaveToExcelFile(@"C:\DocumentList.xls"); } }
public void TableReportTest3() { using (var dataContext = new DataContext()) { var repo = new ReportRepository(dataContext); var reportId = Guid.Parse("{DFBE1017-A975-4A46-9FB3-970B4DC1C67E}"); BizTableReport tableReport = repo.GetReport(reportId); var docDefId = Guid.Parse("{50E90782-110C-4AA0-B4CE-7CB233766F99}"); var docRepo = new DocRepository(dataContext, _userId); int pageCount = 0; List <Guid> docIds = docRepo.List(out pageCount, docDefId, 1, 0); List <Doc> docs = docIds.Select(id => docRepo.LoadById(id)).ToList(); var report = new ExcelTableReport("Тестовое название отчета", docs, tableReport); report.SaveToExcelFile(@"c:\TableReportTest3.xls"); } }
public void TableReportTestWithAgregate() { using (var dataContext = new DataContext()) { var repo = new ReportRepository(dataContext); var reportId = Guid.Parse("{771E695E-2379-4E61-8F9E-F2E28E2D8933}"); BizTableReport tableReport = repo.GetReport(reportId); var docDefId = Guid.Parse("{846B1B55-F110-452F-B08F-8CEB0A112BE0}"); var docRepo = new DocRepository(dataContext, _userId); int pageCount = 0; List <Guid> docIds = docRepo.List(out pageCount, docDefId, 1, 0); List <Doc> docs = docIds.Select(id => docRepo.LoadById(id)).ToList(); var report = new ExcelTableReport("Отчет с агрегатами", docs, tableReport); report.SaveToExcelFile(@"c:\TableReportAggregates.xls"); } }
public void TableReportTest() { using (var dataContext = new DataContext()) { var repo = new ReportRepository(dataContext); var reportId = Guid.Parse("295690be-7d94-43f4-bfc8-37b2fcc936c5"); BizTableReport tableReport = repo.GetReport(reportId); var docDefId = Guid.Parse("{4455B9CB-2564-4A92-A295-E3C0BEDB7AC2}"); var docRepo = new DocRepository(dataContext, _userId); int pageCount = 0; List <Guid> docIds = docRepo.List(out pageCount, docDefId, 1, 0); List <Doc> docs = docIds.Select(id => docRepo.LoadById(id)).ToList(); var report = new ExcelTableReport("Тестовое название отчета", docs, tableReport); report.SaveToExcelFile(@"c:\TableReportTest.xls"); } }
public JsonResult UdtDocument(Doc _param) { int result = 0; try { DaoFactory.BeginTransaction(); DObjectRepository.UdtDObject(_param); DocRepository.UdtDocObject(_param); DaoFactory.Commit(); } catch (Exception ex) { DaoFactory.Rollback(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } return(Json(result)); }
public void XlsFormDefBuilderTest() { using (var dataContext = new DataContext()) { var formRepo = new FormRepository(dataContext); var form = formRepo.GetDetailForm(Guid.Parse("{90958557-E6B0-40A8-88D8-75B71130D5FC}")); var docRepo = new DocRepository(dataContext); var doc = docRepo.LoadById(Guid.Parse("626b662c-17a9-4f70-9a06-13d2337a681a")); var defBuilder = new XlsFormDefBuilder(dataContext, form, Guid.Empty); var def = defBuilder.Build(doc); def.Style.Borders = TableCellBorder.All; var builder = new XlsBuilder(def); var workbook = builder.Build(); using (var stream = new FileStream(@"c:\distr\cissa\testXlsDefAppForm.xls", FileMode.Create)) { workbook.Write(stream); } } }
// 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)); }
// 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)); }
public JsonResult SelDoc(Doc _param) { List <Doc> lDoc = DocRepository.SelDoc(_param); return(Json(lDoc)); }
// 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)); }
// 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)); }