Ejemplo n.º 1
0
        /// <summary>
        /// Previews EForm
        /// </summary>
        /// <param name="eform"></param>
        private void PreviewEForm(Eform eform)
        {
            PreviewPanel.Visible = true;
            // set eform title
            EFormName.Text = eform.Name;

            //PreviewEFormPage.BuildPage(eform.Pages[0]);
        }
Ejemplo n.º 2
0
        /// <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;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Writes the EForm to the Response
        /// </summary>
        private void WriteEForm()
        {
            Response.Clear();
            Eform eform = ObjectSerializer.InstanceFromJSON <Eform>(JSONEForm);

            if (OutputType == OUTPUT_JSON)
            {
                WriteJSON(eform);
            }
            else if (OutputType == OUTPUT_XML)
            {
                WriteXML(eform);
            }

            Response.End();
        }
Ejemplo n.º 4
0
 /// <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();
             }
         }
     }
 }
Ejemplo n.º 5
0
        public GetEform()
            : base()
        {
            this.Init += (a, b) =>
            {
                // create sample blank form
                _eform = new Eform();
                EformPage page = new EformPage();
                page.Sections = new EformSection[] { new EformSection() };
                _eform.Pages  = new EformPage[] { page };

                // default eform id and JSON eform from client POST
                EFormId.Value  = POSTEFormId;
                JSONData.Value = POSTJSONEform;

                ProcessClientRequest();
            };
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns an Eform object from its JSON representation
        /// </summary>
        /// <param name="JSON">the json string representation of an EForm</param>
        /// <returns></returns>
        private Eform GetEformObject(string JSON)
        {
            Eform eform = ObjectSerializer.InstanceFromJSON <Eform>(JSON);

            return(eform);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Writes the EForm as xml
 /// </summary>
 /// <param name="eform"></param>
 private void WriteXML(Eform eform)
 {
     Response.ContentType = "text/xml";
     eform.ToXml().Save(Response.OutputStream);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Writes the EForm as JSON text
 /// </summary>
 /// <param name="eform"></param>
 private void WriteJSON(Eform eform)
 {
     Response.ContentType = "text/plain";
     Response.Write(eform.ToJSON());
 }