private void BuildWorkflows() { // get dynamic eforms var dynamicEForms = from eform in MetadataEForm.GetAll <MetadataEForm>() let eformName = eform[MetadataEForm.EFormName].ToString() let eformVersionNum = eform[MetadataEForm.EFormVersionNum].ToString() orderby eformName ascending select new { Name = eformName, Disease = eform[MetadataEForm.EFormDisease].ToString(), FileName = string.Empty, EFormType = "dynamic", EFormId = eform[MetadataEForm.MetadataEFormId].ToString(), Active = eformVersionNum != "0" }; // filter by disease if (QueryDiseaseId.HasValue) { dynamicEForms = dynamicEForms.Where(e => e.Disease.Equals(QueryDiseaseName, StringComparison.OrdinalIgnoreCase)); } if (dynamicEForms.Count() > 0) { WorkflowsRptr.DataSource = dynamicEForms; WorkflowsRptr.DataBind(); NoResultsMsg.Visible = false; } }
public AdminEformBuilder() : base() { this.Init += (a, b) => { // build a list of tables which have special attribute Lookup = from table in BusinessObject.GetAllTableNames() where BusinessObject.HasMetadataTableAttribute(table, EFORM_METATABLE_ATTRIBUTE_NAME) && BusinessObject.GetMetadataTableAttribute(table, EFORM_METATABLE_ATTRIBUTE_NAME).ToLower() == bool.TrueString.ToLower() select new TableLookup(table); // Build list of tables and diseases BuildTableOptions(); BuildDiseaseDropDown(); var allEforms = from eform in MetadataEForm.GetAll <MetadataEForm>() let eformName = eform[MetadataEForm.EFormName].ToString() select eformName.Replace("'", "\\'"); // build client array 'Eform 1','Eform 2',etc... if (allEforms.Count() > 0) { ACTIVE_EFORM_ARRAY = "['" + string.Join("','", allEforms.ToArray()) + "']"; } }; this.PreRender += (a, b) => { // register parent table lookup BuildClientTableRulesMap(); }; }
/// <summary> /// /// </summary> protected void BuildEformList(object sender, EventArgs e) { //var staticEForms = from eform in CaisisConfiguration.GetEformsConfigList() // let eformName = eform.Name // orderby eformName ascending // select new // { // Name = eformName, // Disease = eform.Disease, // EFormType = "static", // EFormId = "" // }; var dynamicEForms = from eform in MetadataEForm.GetAll <MetadataEForm>() let eformName = eform[MetadataEForm.EFormName].ToString() let eformVersionNum = eform[MetadataEForm.EFormVersionNum].ToString() orderby eformName ascending select new { Name = eformName, Disease = eform[MetadataEForm.EFormDisease].ToString(), EFormType = "dynamic", EFormId = eform[MetadataEForm.MetadataEFormId].ToString(), Active = eformVersionNum != "0" }; //var allEForms = from eform in staticEForms.Concat(dynamicEForms) // orderby eform.Name ascending // select eform; EFormsRptr.DataSource = dynamicEForms; EFormsRptr.DataBind(); }
/// <summary> /// /// </summary> /// <param name="eformName"></param> private void LoadEForm(string eformName) { // load by name MetadataEForm biz = MetadataEForm.GetByFields <MetadataEForm>(new Dictionary <string, object>() { { MetadataEForm.EFormName, eformName } }).First(); LoadEForm((int)biz[biz.PrimaryKeyName]); }
/// <summary> /// Inserts the EForm object into DB /// </summary> /// <param name="eform"></param> private void SaveEForm(Eform eform) { // default version number string versionNumber = "0"; // ??? version number used for active bit, on insert, turn on, on exisitng, use prvious value if (!string.IsNullOrEmpty(POSTEFormId)) { MetadataEForm prevEform = new MetadataEForm(); prevEform.Get(int.Parse(POSTEFormId)); versionNumber = prevEform[MetadataEForm.EFormVersionNum].ToString(); } EformMetadataBuilder builder = new EformMetadataBuilder(eform.Name, eform.Disease, versionNumber); foreach (EformPage page in eform.Pages) { builder.NewPage(page.Title, "1"); for (int i = 0; i < page.Sections.Length; i++) { EformSection section = page.Sections[i]; ProcessSection(builder, section, i); } } // after traversing, save builder.Save(); // update eform id hidden // locate inserted record MetadataEForm biz = new MetadataEForm(); // after save, if existing eform exists, remove duplicate if (!string.IsNullOrEmpty(POSTEFormId))// && POSTEFormId != EFormId.Value) { int eformId = int.Parse(POSTEFormId); biz.Delete(eformId); biz = GetEFormbyName(eform.Name); EFormId.Value = biz[MetadataEForm.MetadataEFormId].ToString(); // set client message OperationMessage.Value = string.Empty; } else { biz = GetEFormbyName(eform.Name); EFormId.Value = biz[MetadataEForm.MetadataEFormId].ToString(); // set client message OperationMessage.Value = string.Empty; } }
/// <summary> /// /// </summary> /// <param name="eid"></param> private void LoadEForm(int eid) { // load by id MetadataEForm biz = new MetadataEForm(); biz.Get(eid); // set name and id fields EformName.Value = biz[MetadataEForm.EFormName].ToString(); EformId.Value = biz[MetadataEForm.MetadataEFormId].ToString(); DiseaseList.SelectedValue = biz[MetadataEForm.EFormDisease].ToString(); }
/// <summary> /// Delegate approriate method based on client params /// </summary> private void ProcessClientRequest() { // determine method called if (!string.IsNullOrEmpty(QueryMethodName)) { // with eform, process if (!string.IsNullOrEmpty(POSTJSONEform)) { Eform eform = GetEformObject(POSTJSONEform); if (QueryMethodName == METHOD_SAVE_EFORM) { // insert eform data SaveEForm(eform); } else if (QueryMethodName == METHOD_PREVIEW_EFORM) { PreviewEForm(eform); } } else { if (QueryMethodName == METHOD_LOAD_EFORM && !string.IsNullOrEmpty(POSTEFormId)) { MetadataEForm biz = new MetadataEForm(); biz.Get(int.Parse(POSTEFormId)); BuildPageFromEForm(biz[MetadataEForm.EFormName].ToString()); EFormSectionPanel.Visible = true; } else if (QueryMethodName == METHOD_GET_ITEMS && !string.IsNullOrEmpty(QueryTable)) { ToolboxPanel.Visible = true; BuildToolboxItems(QueryTable); } else if (QueryMethodName == METHOD_GET_SECTION || QueryMethodName == METHOD_GET_SUB_SECTION) { BuildBlankPage(); EFormSectionPanel.Visible = true; } else if (QueryMethodName == METHOD_DELETE_EFORM) { DeleteEForm(); } } } }
/// <summary> /// Updates the workflow active status /// </summary> private void ProcessAJAXRequest() { string method = Request.Form["method"]; if (!string.IsNullOrEmpty(method)) { if (method == "setEFormActive") { int eformId = int.Parse(Request.Form["eformId"]);; bool isActive = bool.Parse(Request.Form["isActive"]); MetadataEForm biz = new MetadataEForm(); biz.Get(eformId); biz[MetadataEForm.EFormVersionNum] = isActive ? 1 : 0; biz.Save(); Response.End(); } } }
/// <summary> /// /// </summary> private void DeleteEForm() { // validate eform id passed in FORM if (!string.IsNullOrEmpty(POSTEFormId)) { int eformId = int.Parse(POSTEFormId); MetadataEForm biz = new MetadataEForm(); biz.Delete(eformId); // update hidden field EFormId.Value = string.Empty; OperationMessage.Value = string.Empty; } else { // update hidden field EFormId.Value = POSTEFormId; OperationMessage.Value = "EFORM NOT DELETED, NO EFORM TO DELETE."; } }
/// <summary> /// Updates MetadataEform active bit /// </summary> protected void UpdateEformActiveBit(object sender, EventArgs e) { CheckBox activeEformCheckBox = sender as CheckBox; HiddenField idField = activeEformCheckBox.NamingContainer.FindControl("MetaEformId") as HiddenField; MetadataEForm biz = new MetadataEForm(); biz.Get(int.Parse(idField.Value)); // ?? using version number field until true db bit field // mark as active if (activeEformCheckBox.Checked) { biz[MetadataEForm.EFormVersionNum] = 1; } // mark as inactive else { biz[MetadataEForm.EFormVersionNum] = 0; } biz.Save(); }