public async Task <JsonResult> ListFields(string documentId, string appId) { var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.DocumentTypes == null) { appModule.DocumentTypes = new List <DocumentType>(); } var docService = new DocumentTypeServices(_appModuleRepository); var fields = await docService.FindDocumentTypeFields(appId, ObjectId.Parse(documentId)); var result = new JsonGenericResult { IsSuccess = true, Result = fields }; return(Json(result, JsonRequestBehavior.AllowGet)); } var errorResult = new JsonGenericResult { IsSuccess = true, Result = appModule.DocumentTypes.FirstOrDefault(n => n.Id.ToString().ToLower().Trim() == documentId.ToLower().Trim()).Fields }; return(Json(errorResult, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteDocumentType(long id) { var gVal = new GenericValidator(); try { if (id < 1) { gVal.Code = -1; gVal.Error = "Invalid selection"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var delStatus = new DocumentTypeServices().DeleteDocumentType(id); if (delStatus < 1) { gVal.Code = -1; gVal.Error = "Document Type could not be deleted. Please try again later."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = 5; gVal.Error = "Document Type Information was successfully deleted"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteDocumentType(long id) { var gVal = new GenericValidator(); try { if (id < 1) { gVal.Code = -1; gVal.Error = message_Feedback.Invalid_Selection; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var k = new DocumentTypeServices().DeleteDocumentType(id); if (k) { gVal.Code = 5; gVal.Error = "Document Type information was successfully deleted."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = -1; gVal.Error = "Document Type information could not be deleted."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = 5; gVal.Error = "Document Type information could not be deleted."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public DocumentsController(DocumentTypeServices documentTypeServices, DocumentService documentService, PlantService plantService, DocumentHistoryService documentHistoryService) { this._documentTypeServices = documentTypeServices; this._documentService = documentService; this._plantService = plantService; this._documentHistoryService = documentHistoryService; }
public ActionResult EditDocumentType(DocumentTypeObject documentType) { var gVal = new GenericValidator(); try { if (ModelState.IsValid) { var valStatus = ValidateDocumentType(documentType); if (valStatus.Code < 1) { gVal.Code = -1; gVal.Error = valStatus.Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_documentType"] == null) { gVal.Code = -1; gVal.Error = message_Feedback.Session_Time_Out; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldDocumentType = Session["_documentType"] as DocumentTypeObject; if (oldDocumentType == null || oldDocumentType.DocumentTypeId < 1) { gVal.Code = -1; gVal.Error = message_Feedback.Session_Time_Out; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldDocumentType.TypeName = documentType.TypeName.Trim(); if (!string.IsNullOrEmpty(documentType.Description)) { oldDocumentType.Description = documentType.Description.Trim(); } var k = new DocumentTypeServices().UpdateDocumentType(oldDocumentType); if (k < 1) { gVal.Code = -1; gVal.Error = k == -3 ? "Document Type information already exists" : "Document Type information could not be updated. Please try again"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = 5; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = -1; gVal.Error = message_Feedback.Model_State_Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = -1; gVal.Error = message_Feedback.Process_Failed; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> RenderDetail(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.DataViews != null) { ViewBag.AppId = appModule.Id.ToString(); ViewBag.AppName = appModule.Name; ViewBag.DataId = dataId; ViewBag.DataParentId = id; 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); } else { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.DocumentTypeId); } //var documentName = await docTypeService.FindDocumentTypeName(appId, dataView.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, ""); //var data = await dataService.Get(dataId); //var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; //response.Data = data.ToJson(jsonWriterSettings); return(View(response)); } } return(View(response)); } return(View(new DataView())); } } return(View()); }
public ActionResult EditDocumentType(DocumentTypeObject documentType) { var gVal = new GenericValidator(); try { if (!ModelState.IsValid) { gVal.Code = -1; gVal.Error = "Plese provide all required fields and try again."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var stat = ValidateDocumentType(documentType); if (stat.Code < 1) { return(Json(gVal, JsonRequestBehavior.AllowGet)); } if (Session["_DocumentType"] == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var oldDocumentType = Session["_DocumentType"] as DocumentTypeObject; if (oldDocumentType == null) { gVal.Code = -1; gVal.Error = "Session has timed out."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } oldDocumentType.Name = documentType.Name.Trim(); var docStatus = new DocumentTypeServices().UpdateDocumentType(oldDocumentType); if (docStatus < 1) { gVal.Code = -1; gVal.Error = docStatus == -3 ? "Document Type already exists." : "Document Type information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = oldDocumentType.DocumentTypeId; gVal.Error = "Document Type information was successfully updated"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Code = -1; gVal.Error = "Document Type information could not be updated. Please try again later"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetDocumentTypeObjects(JQueryDataTableParamModel param) { try { IEnumerable <DocumentTypeObject> filteredDocumentTypeObjects; var countG = new DocumentTypeServices().GetObjectCount(); var pagedDocumentTypeObjects = GetDocumentTypes(param.iDisplayLength, param.iDisplayStart); if (!string.IsNullOrEmpty(param.sSearch)) { filteredDocumentTypeObjects = new DocumentTypeServices().Search(param.sSearch); } else { filteredDocumentTypeObjects = pagedDocumentTypeObjects; } if (!filteredDocumentTypeObjects.Any()) { return(Json(new List <DocumentTypeObject>(), JsonRequestBehavior.AllowGet)); } //var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); Func <DocumentTypeObject, string> orderingFunction = (c => c.TypeName); var sortDirection = Request["sSortDir_0"]; // asc or desc filteredDocumentTypeObjects = sortDirection == "asc" ? filteredDocumentTypeObjects.OrderBy(orderingFunction) : filteredDocumentTypeObjects.OrderByDescending(orderingFunction); var displayedUserProfilenels = filteredDocumentTypeObjects; var result = from c in displayedUserProfilenels select new[] { Convert.ToString(c.DocumentTypeId), c.TypeName }; return(Json(new { param.sEcho, iTotalRecords = countG, iTotalDisplayRecords = filteredDocumentTypeObjects.Count(), aaData = result }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message); return(Json(new List <DocumentTypeObject>(), JsonRequestBehavior.AllowGet)); } }
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 ActionResult AddDocumentType(DocumentTypeObject documentType) { var gVal = new GenericValidator(); try { if (!ModelState.IsValid) { gVal.Code = -1; gVal.Error = "Plese provide all required fields and try again."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var importerInfo = GetLoggedOnUserInfo(); if (importerInfo.Id < 1) { gVal.Error = "Your session has timed out"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var validationResult = ValidateDocumentType(documentType); if (validationResult.Code == 1) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var appStatus = new DocumentTypeServices().AddDocumentType(documentType); if (appStatus < 1) { validationResult.Code = -1; validationResult.Error = appStatus == -2 ? "Document Type could not be added. Please try again." : "The Document Type Information already exists"; return(Json(validationResult, JsonRequestBehavior.AllowGet)); } gVal.Code = appStatus; gVal.Error = "Document Type was successfully added."; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch (Exception) { gVal.Error = "Document Type processing failed. Please try again later"; gVal.Code = -1; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetDocumentType(long id) { try { var documentType = new DocumentTypeServices().GetDocumentType(id); if (documentType == null || documentType.DocumentTypeId < 1) { return(Json(new DocumentTypeObject(), JsonRequestBehavior.AllowGet)); } Session["_DocumentType"] = documentType; return(Json(documentType, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new DocumentTypeObject(), JsonRequestBehavior.AllowGet)); } }
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()); }
public async Task <ActionResult> RenderForm(string appId, string reqFormId) { if (!string.IsNullOrEmpty(appId)) { var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.Forms != null) { ViewBag.AppId = appModule.Id.ToString(); ObjectId formId; if (ObjectId.TryParse(reqFormId, out formId)) { if (appModule.Forms.Any(n => n.Id == formId)) { var form = appModule.Forms.FirstOrDefault(n => n.Id == formId); var response = new ResRenderForm(); response.Form = form; var docTypeService = new DocumentTypeServices(_appModuleRepository); if (form.SubDocumentTypeId != null && form.SubDocumentTypeId != ObjectId.Empty) { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, form.SubDocumentTypeId.Value); } else { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, form.DocumentTypeId); } return(View(response)); } } } return(View(new ResRenderForm())); } } return(View(new List <ModuleForm>())); }
public ActionResult AddDocumentType(DocumentTypeObject documentType) { var gVal = new GenericValidator(); try { if (ModelState.IsValid) { var valStatus = ValidateDocumentType(documentType); if (valStatus.Code < 1) { gVal.Code = -1; gVal.Error = valStatus.Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } var k = new DocumentTypeServices().AddDocumentType(documentType); if (k < 1) { gVal.Code = -1; gVal.Error = k == -3 ? "Document Type information already exists" : "Document Type information could not be updated. Please try again"; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = 5; return(Json(gVal, JsonRequestBehavior.AllowGet)); } gVal.Code = -1; gVal.Error = message_Feedback.Model_State_Error; return(Json(gVal, JsonRequestBehavior.AllowGet)); } catch { gVal.Code = -1; gVal.Error = message_Feedback.Process_Failed; return(Json(gVal, JsonRequestBehavior.AllowGet)); } }
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 ActionResult GetDocumentType(long id) { var gVal = new GenericValidator(); try { if (id < 1) { return(Json(new DocumentTypeObject(), JsonRequestBehavior.AllowGet)); } var documentType = new DocumentTypeServices().GetDocumentType(id); if (id < 1) { return(Json(new DocumentTypeObject(), JsonRequestBehavior.AllowGet)); } Session["_documentType"] = documentType; return(Json(documentType, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new DocumentTypeObject(), JsonRequestBehavior.AllowGet)); } }
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 <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)); }