public async Task <ActionResult> RenderLineChart(string appId, string id, string dataId) { if (!string.IsNullOrEmpty(appId)) { var response = new ResRenderTabular(); var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.Forms != null) { ViewBag.AppId = appModule.Id.ToString(); ViewBag.AppName = appModule.Name; ViewBag.DataId = dataId; ObjectId dataViewId; if (ObjectId.TryParse(id, out dataViewId)) { if (appModule.DataViews.Any(n => n.Id == dataViewId)) { var dataView = appModule.DataViews.FirstOrDefault(n => n.Id == dataViewId); response.DataView = dataView; var docTypeService = new DocumentTypeServices(_appModuleRepository); if (dataView.SubDocumentTypeId.HasValue) { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.SubDocumentTypeId.Value); ViewBag.DocumentTypeName = await docTypeService.FindDocumentTypeName(appId, dataView.SubDocumentTypeId.Value); } else { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.DocumentTypeId); ViewBag.DocumentTypeName = await docTypeService.FindDocumentTypeName(appId, dataView.DocumentTypeId); } return(View(response)); } } return(View(response)); } return(View(new DataView())); } } return(View()); }
public async Task <JsonResult> FetchData(ReqData req) { var appModule = await _appModuleRepository.Get(req.AppId); var docTypeService = new DocumentTypeServices(_appModuleRepository); ObjectId documentTypeId; ObjectId.TryParse(req.DocumentTypeId, out documentTypeId); var documentName = await docTypeService.FindDocumentTypeName(req.AppId, documentTypeId); var rootDocumentName = documentName; var org = await _organisationRepository.Get(appModule.OrganisationId); var dataService = new DataService(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString, org.Id.ToString(), documentName); //var data = await dataService.Get(dataId, ""); BsonDocument data; if (!string.IsNullOrEmpty(req.SubDocumentTypeId)) { ObjectId subDocumentTypeId; ObjectId.TryParse(req.SubDocumentTypeId, out subDocumentTypeId); documentName = await docTypeService.FindDocumentTypeName(req.AppId, subDocumentTypeId); var subDocumentHierarchy = await docTypeService.FindSubDocumentHierarchy(req.AppId, documentTypeId, documentName, rootDocumentName); data = await dataService.Get(req.DataId, subDocumentHierarchy); } else { data = await dataService.Get(req.DataId); } var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; var result = new JsonGenericResult { IsSuccess = true, Result = data.ToJson(jsonWriterSettings) }; return(Json(result)); }
public async Task <ActionResult> EditForm(string appId, string formId) { if (!string.IsNullOrEmpty(appId)) { var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.Forms != null) { ViewBag.AppId = appModule.Id.ToString(); ViewBag.AppName = appModule.Name; ObjectId moduleFormId; if (ObjectId.TryParse(formId, out moduleFormId)) { if (appModule.Forms.Any(n => n.Id == moduleFormId)) { var form = appModule.Forms.FirstOrDefault(n => n.Id == moduleFormId); var docSrvc = new DocumentTypeServices(_appModuleRepository); var documentName = await docSrvc.FindDocumentTypeName(appId, form.DocumentTypeId); ViewBag.SubDocumentName = "None"; if (form.SubDocumentTypeId != null) { var sudDocName = await docSrvc.FindDocumentTypeName(appId, form.SubDocumentTypeId.Value); ViewBag.SubDocumentName = sudDocName; } ViewBag.DocumentName = documentName; return(View(form)); } } return(View(appModule.Forms)); } return(View(new ModuleForm())); } } return(View()); }
private async Task <DataView> GetDataView(string appId, string id) { if (!string.IsNullOrEmpty(appId)) { var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.Forms != null) { ViewBag.AppId = appModule.Id.ToString(); ViewBag.AppName = appModule.Name; ObjectId dataViewId; if (ObjectId.TryParse(id, out dataViewId)) { if (appModule.DataViews.Any(n => n.Id == dataViewId)) { var dataView = appModule.DataViews.FirstOrDefault(n => n.Id == dataViewId); var docService = new DocumentTypeServices(_appModuleRepository); ViewBag.DocumentTypeName = await docService.FindDocumentTypeName(appId, dataView.DocumentTypeId); ViewBag.SubDocumentTypeName = "none"; if (dataView.SubDocumentTypeId.HasValue) { ViewBag.SubDocumentTypeName = await docService.FindDocumentTypeName(appId, dataView.SubDocumentTypeId.Value); } return(dataView); } } } } } return(new DataView()); }
public async Task <JsonResult> Insert(ReqAddData req) { try { if (!string.IsNullOrEmpty(req.appId)) { var appModule = await _appModuleRepository.Get(req.appId); if (appModule != null) { if (appModule.Forms == null) { appModule.Forms = new List <ModuleForm>(); } ObjectId formId; if (ObjectId.TryParse(req.foreignId, out formId)) { var form = appModule.Forms.FirstOrDefault(n => n.Id == formId); var result = new JsonGenericResult { IsSuccess = true, Result = form }; var org = await _organisationRepository.Get(appModule.OrganisationId); var docTypeService = new DocumentTypeServices(_appModuleRepository); var documentName = await docTypeService.FindDocumentTypeName(req.appId, form.DocumentTypeId); var parentDocumentName = documentName == req.ParentDocumentName ? "" : req.ParentDocumentName; var dataService = new DataService(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString, org.Id.ToString(), documentName); var serializer = new JavaScriptSerializer(); if (form.SubDocumentTypeId != null && form.SubDocumentTypeId != ObjectId.Empty) { var subDocumentName = await docTypeService.FindDocumentTypeName(req.appId, form.SubDocumentTypeId.Value); var rootDocumentName = await docTypeService.FindDocumentTypeName(req.appId, form.DocumentTypeId); var parentHeirarchy = await docTypeService.FindSubDocumentHierarchy(req.appId, form.DocumentTypeId, subDocumentName, rootDocumentName); parentHeirarchy = parentHeirarchy.Replace(subDocumentName, ""); if (parentHeirarchy.Length > 1) { if (parentHeirarchy.Substring(parentHeirarchy.Length - 1, 1) == ".") { parentHeirarchy = parentHeirarchy.Substring(0, parentHeirarchy.Length - 1); } } //await dataService.Add(req.data, req.RootDataId, subDocumentName, parentDocumentName); await dataService.Add(req.data, req.RootDataId, subDocumentName, parentHeirarchy); } else { dataService.Add(req.data); } return(Json(result)); } } } var ErrorResult = new JsonGenericResult { IsSuccess = false, Message = "No app selected." }; return(Json(ErrorResult)); } catch (Exception ex) { return(Json(new JsonGenericResult { IsSuccess = false, Message = ex.Message })); } }
public async Task <ActionResult> RenderTabular(string appId, string id, string dataId) { if (!string.IsNullOrEmpty(appId)) { var response = new ResRenderTabular(); var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.Forms != null) { ViewBag.AppId = appModule.Id.ToString(); ViewBag.AppName = appModule.Name; ViewBag.DataId = dataId; ObjectId dataViewId; if (ObjectId.TryParse(id, out dataViewId)) { if (appModule.DataViews.Any(n => n.Id == dataViewId)) { var dataView = appModule.DataViews.FirstOrDefault(n => n.Id == dataViewId); response.DataView = dataView; var docTypeService = new DocumentTypeServices(_appModuleRepository); if (dataView.SubDocumentTypeId.HasValue) { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.SubDocumentTypeId.Value); ViewBag.DocumentTypeName = await docTypeService.FindDocumentTypeName(appId, dataView.SubDocumentTypeId.Value); } else { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.DocumentTypeId); ViewBag.DocumentTypeName = await docTypeService.FindDocumentTypeName(appId, dataView.DocumentTypeId); } //var org = await _organisationRepository.Get(appModule.OrganisationId); //var documentName = await docTypeService.FindDocumentTypeName(appId, dataView.DocumentTypeId); //var dataService = new DataService(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString, org.Id.ToString(), documentName); //var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; //if (dataView.SubDocumentTypeId.HasValue) //{ // if (dataId != null) // { // var subDocumentName = await docTypeService.FindDocumentTypeName(appId, dataView.SubDocumentTypeId.Value); // var suDocData = await dataService.ListAll(ObjectId.Parse(dataId), subDocumentName); // response.Data = suDocData.ToJson(jsonWriterSettings); // } //} //else //{ // var data = await dataService.ListAll(); // response.Data = data.ToJson(jsonWriterSettings); //} return(View(response)); } } return(View(response)); } return(View(new DataView())); } } return(View()); }
public async Task <JsonResult> FetchListData(ReqData req) { var appModule = await _appModuleRepository.Get(req.AppId); var docTypeService = new DocumentTypeServices(_appModuleRepository); ObjectId documentTypeId; ObjectId.TryParse(req.DocumentTypeId, out documentTypeId); var documentName = await docTypeService.FindDocumentTypeName(req.AppId, documentTypeId); var org = await _organisationRepository.Get(appModule.OrganisationId); var dataService = new DataService(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString, org.Id.ToString(), documentName); //var data = await dataService.Get(dataId, ""); Object data = null; //if (!string.IsNullOrEmpty(req.SubDocumentTypeId)) //{ // ObjectId subDocumentTypeId; // ObjectId.TryParse(req.SubDocumentTypeId, out subDocumentTypeId); // documentName = await docTypeService.FindDocumentTypeName(req.AppId, subDocumentTypeId); // data = await dataService.Get(req.DataId, documentName); //} //else //{ // data = await dataService.ListAll(); //} var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; if (!string.IsNullOrEmpty(req.SubDocumentTypeId)) { if (req.DataId != null) { ObjectId subDocumentTypeId; ObjectId.TryParse(req.SubDocumentTypeId, out subDocumentTypeId); var subDocumentName = await docTypeService.FindDocumentTypeName(req.AppId, subDocumentTypeId); var parentSubDocumentName = await docTypeService.FindParentDocumentTypeName(req.AppId, documentTypeId, subDocumentName); var suDocData = await dataService.ListAll(ObjectId.Parse(req.DataId), subDocumentName, parentSubDocumentName); data = suDocData; } } else { data = await dataService.ListAll(); } var result = new JsonGenericResult { IsSuccess = true, Result = data.ToJson(jsonWriterSettings) }; return(Json(result)); }