private void PerformCustomAction(XFormData data, string subject, string to, string from)
        {
            var doc = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"));
            XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";

            // This part uses the xform data to create a custom email with the data as an attachment
            var import = new XElement("Import", new XAttribute(XNamespace.Xmlns + "xsi", xsi));
            import.Add(new XElement("ElementInForm", data.GetValue("elementInForm")));
            doc.Add(import);

            var mailMessage = new MailMessage
            {
                BodyEncoding = Encoding.UTF8,
                SubjectEncoding = Encoding.UTF8,
                IsBodyHtml = false,
                Body = import.ToString(),
                Subject = subject,
            };

            mailMessage.From = new MailAddress(from);
            mailMessage.To.Add(to);

            var customXml = new MemoryStream();
            doc.Save(customXml);
            customXml.Position = 0;

            Attachment xml = new Attachment(customXml, "example.xml", MediaTypeNames.Text.Xml);
            mailMessage.Attachments.Add(xml);
            new SmtpClient().Send(mailMessage);
        }
示例#2
0
        private void PerformCustomAction(XFormData data, string subject, string to, string from)
        {
            var        doc = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"));
            XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";

            // This part uses the xform data to create a custom email with the data as an attachment
            var import = new XElement("Import", new XAttribute(XNamespace.Xmlns + "xsi", xsi));

            import.Add(new XElement("ElementInForm", data.GetValue("elementInForm")));
            doc.Add(import);

            var mailMessage = new MailMessage
            {
                BodyEncoding    = Encoding.UTF8,
                SubjectEncoding = Encoding.UTF8,
                IsBodyHtml      = false,
                Body            = import.ToString(),
                Subject         = subject,
            };

            mailMessage.From = new MailAddress(from);
            mailMessage.To.Add(to);

            var customXml = new MemoryStream();

            doc.Save(customXml);
            customXml.Position = 0;

            Attachment xml = new Attachment(customXml, "example.xml", MediaTypeNames.Text.Xml);

            mailMessage.Attachments.Add(xml);
            new SmtpClient().Send(mailMessage);
        }
        public static NameValueCollection GetFormData(IParticipant participant)
        {
            NameValueCollection _formControls = new NameValueCollection();

            if (participant.XForm != null)
            {
                SerializableXmlDocument xmlDoc = new SerializableXmlDocument();
                xmlDoc.LoadXml(participant.XForm);
                XFormData data = new XFormData();
                data.Data = xmlDoc;
                NameValueCollection formControls = data.GetValues();
                _formControls = formControls;
            }
            return(_formControls);
        }
示例#4
0
        protected void ImportParticipant(EventPageBase ep, string[] participantFields, string[] keys)
        {
            string    email           = "";
            Hashtable fieldsHashtable = new Hashtable();

            if (participantFields.Count() == keys.Count())
            {
                for (int i = 0; i < keys.Count(); i++)
                {
                    if (!fieldsHashtable.ContainsKey(keys[i]))
                    {
                        fieldsHashtable.Add(keys[i].ToLower(), participantFields[i]);
                    }
                }
            }

            if (fieldsHashtable.ContainsKey("email"))
            {
                email = fieldsHashtable["email"].ToString();
            }
            else
            {
                return;
            }
            if (string.IsNullOrEmpty(email))
            {
                return;
            }

            XForm xform = ep.RegistrationForm;

            XFormData xFormData = xform.CreateFormData();

            PopulateChildNodeRecursive(fieldsHashtable, xFormData.Data.ChildNodes);


            string xformstring = xFormData.Data.InnerXml;

            StatusLiteral.Text += "Adding participant: " + email + "<br/>";
            AttendRegistrationEngine.GenerateParticipation(ep.ContentLink, email, false, xformstring,
                                                           "Imported participant from text");
        }
示例#5
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            UnifiedFile selectedFile = FileManager.SingleSelectedFile;

            // Init the XForm.
            SerializableXmlDocument rawFile = new SerializableXmlDocument();
            VirtualFile             vf      = HostingEnvironment.VirtualPathProvider.GetFile(selectedFile.Parent.CustomFileSummaryVirtualPath);

            using (Stream stream = vf.Open())
            {
                rawFile.Load(stream);
            }
            XForm form = new XForm();

            form.Document = rawFile;
            _data         = form.CreateFormData();

            // Populate the XForm.
            IDictionary dict = selectedFile.Summary.Dictionary;

            foreach (DictionaryEntry entry in dict)
            {
                if (entry.Value != null)
                {
                    _data.SetValue(entry.Key.ToString(), entry.Value.ToString());
                }
            }
            XFormCtrl.Data           = _data;
            XFormCtrl.FormDefinition = form;

            if (!FileSystemUtility.CanEdit(selectedFile))
            {
                SaveButton.Enabled = false;
                Page.Validators.Add(new StaticValidator(Translate("/filemanager/errormessage/cannotchange")));
            }
        }
        public static NameValueCollection GetFormData(IParticipant participant)
        {
            NameValueCollection _formControls = new NameValueCollection();
            if (participant.XForm != null)
            {
                SerializableXmlDocument xmlDoc = new SerializableXmlDocument();
                xmlDoc.LoadXml(participant.XForm);
                XFormData data = new XFormData();
                data.Data = xmlDoc;
                NameValueCollection formControls = data.GetValues();
                _formControls = formControls;

            }
            return _formControls;
        }