Exemple #1
0
        public HttpResponseMessage Lucu4()
        {
            CreateOdkForm   punuk = new CreateOdkForm();
            List <FormItem> pakan = new List <FormItem>();

            pakan.Add(new FormItem()
            {
                value = "horror", label = "horror"
            });
            pakan.Add(new FormItem()
            {
                value = "fantasy", label = "fantasy"
            });
            pakan.Add(new FormItem()
            {
                value = "funny", label = "funny"
            });
            punuk.createInputForm(nameof(Buku.title), "whats the title?", new Tipe().TipeString, new Required().TRUE, null);
            punuk.createSelect1Form(nameof(Buku.genre), "what is the genre?", null, null, null, pakan);
            punuk.createInputForm(nameof(Buku.author), "whats the name of the author?", new Tipe().TipeString, new Required().TRUE, null);
            return(new HttpResponseMessage {
                Content = new StringContent(punuk.createTheForm("kampan", 1).ToString()), StatusCode = HttpStatusCode.OK
            });
        }
Exemple #2
0
        public HttpResponseMessage Gendeng()
        {
            //if (Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\forms")))
            //{
            using (var stringWriter = new StringWriter())

                using (XmlWriter writer = XmlWriter.Create(stringWriter))
                {
                    writer.WriteStartElement("xforms", "http://openrosa.org/xforms/xformsList");
                    writer.WriteAttributeString("xmlns", "http://openrosa.org/xforms/xformsList");
                    //string[] array1 = Directory.GetFiles(System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\forms"),"*.xml");
                    CreateOdkForm   punuk = new CreateOdkForm();
                    List <FormItem> pakan = new List <FormItem>();
                    pakan.Add(new FormItem()
                    {
                        value = "horror", label = "horror"
                    });
                    pakan.Add(new FormItem()
                    {
                        value = "fantasy", label = "fantasy"
                    });
                    pakan.Add(new FormItem()
                    {
                        value = "funny", label = "funny"
                    });
                    punuk.createInputForm(nameof(Book.Title), "whats the title?", new Tipe().TipeString, new Required().TRUE, null);
                    punuk.createSelectForm(nameof(Book.Genre), "what is the genre?", null, null, pakan);
                    punuk.createInputForm(nameof(Book.Author), "whats the name of the author?", new Tipe().TipeString, new Required().TRUE, null);
                    punuk.createInputForm("wow", "whats the name of the intent?", new Tipe().TipeBarcode, null, null);

                    //foreach (string a in array1) {
                    //XmlDocument doc = new XmlDocument();
                    //doc.LoadXml(File.ReadAllText(@a));
                    //XmlNodeList punuk = doc.GetElementsByTagName("instance");
                    //string name= doc.GetElementsByTagName("h:title")[0].InnerText;
                    //string id = punuk[0].FirstChild.Name;
                    //string version = punuk[0].FirstChild.Attributes["version"]==null?null: punuk[0].FirstChild.Attributes["version"].Value;
                    string md5          = "md5:" + MD5Hash(punuk.createTheForm(nameof(Book), 1).ToString());
                    string downloadForm = nameof(Book);
                    writer.WriteStartElement("xform");
                    writer.WriteElementString("name", nameof(Book));
                    writer.WriteElementString("formID", nameof(Book));
                    writer.WriteElementString("hash", md5);
                    //if (version != null) {
                    writer.WriteElementString("version", "1");
                    //}
                    writer.WriteElementString("downloadUrl", "https://" + HttpContext.Current.Request.Url.Host + "/downloadform/" + Base64Encode(nameof(Book)));

                    if (Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\forms\\" + nameof(Book) + "-media")))
                    {
                        writer.WriteElementString("manifestUrl", "https://" + HttpContext.Current.Request.Url.Host + "/downloadmanifest/" + Base64Encode(nameof(Book) + "-media"));
                    }
                    writer.WriteEndElement();

                    //}

                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                    writer.Flush();
                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(stringWriter.GetStringBuilder().ToString(), Encoding.UTF8, "text/xml"), StatusCode = HttpStatusCode.OK
                    });
                }
            //}
            //else {
            //    return new HttpResponseMessage() { Content = new StringContent("Directory forms not found"), StatusCode = HttpStatusCode.NotFound };
            //}
        }