示例#1
0
        public void Save(object value, System.IO.Stream s)
        {
            SerializableXmlDocument doc;

            if (value is SerializableXmlDocument)
            {
                doc = value as SerializableXmlDocument;
            }
            else
            {
                doc = new SerializableXmlDocument();
                doc.LoadXml((value as XmlDocument).InnerXml);

                // FIXME: very inefficient.
                Common.Warning(typeof(XmlLoadableFactory), "Unefficient saving of object, " +
                               "try using SerializableXmlDocument instead of XmlDocument.");
            }
            try
            {
                doc.Save(s);
            }
            catch (Exception e)
            {
                Common.WarningFormatted(typeof(XmlLoadableFactory),
                                        "Could not save Xml document to stream '{0}': {1}", s, e);
                throw;
            }
        }
示例#2
0
        protected override void OnInit(EventArgs e)
        {
            DetailsXFormControl.FormDefinition = XForm.CreateInstance(new Guid((CurrentData as EventPageBase).RegistrationForm.Id.ToString()));

            string email = Request.QueryString["email"];
            string code  = Request.QueryString["code"];

            HiddenCode.Value  = code;
            HiddenEmail.Value = email;


            if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(code))
            {
                IParticipant participant = AttendRegistrationEngine.GetParticipant(email, code);
                if (participant != null)
                {
                    SerializableXmlDocument xmlDoc = new SerializableXmlDocument();
                    xmlDoc.LoadXml(participant.XForm);
                    DetailsXFormControl.Data.Data = xmlDoc;
                }
            }

            SessionsPanel.Controls.Add(AttendSessionEngine.GetSessionsControl(CurrentData.ContentLink, null));
            SessionsPanel.DataBind();
            base.OnInit(e);
        }
示例#3
0
 protected void PopulateForm()
 {
     if (!string.IsNullOrEmpty(CurrentData.XForm))
     {
         SerializableXmlDocument xmlDoc = new SerializableXmlDocument();
         xmlDoc.LoadXml(CurrentData.XForm);
         DetailsXFormControl.Data.Data = xmlDoc;
     }
 }
        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);
        }
示例#5
0
        public object Load(System.IO.Stream s)
        {
            SerializableXmlDocument doc = new SerializableXmlDocument();

            try
            {
                doc.Load(s);
                return(doc);
            }
            catch (Exception e)
            {
                Common.WarningFormatted(typeof(XmlLoadableFactory),
                                        "Could not load Xml document from stream '{0}': {1}", s, e);
                return(null);
            }
        }
示例#6
0
            public override bool Equals(object obj)
            {
                SerializableXmlDocument other = obj as SerializableXmlDocument;

                if (other == null)
                {
                    return(false);
                }

                StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);

                Document.Save(writer);
                StringWriter otherWriter = new StringWriter(CultureInfo.InvariantCulture);

                other.Document.Save(otherWriter);

                return(String.Equals(writer.ToString(), otherWriter.ToString()));
            }
示例#7
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")));
            }
        }
示例#8
0
        private void CacheDeserialization()
        {
            Child.InstallEnvironment = environment;
            SerializableXmlDocument doc = Child.OpenForReading <SerializableXmlDocument>().Object;

            doc.Normalize();

            XmlElement node = doc.FirstChild.NextSibling as XmlElement;

            // assert root node
            if (node.Name != "Application")
            {
                throw new AbortInstallationException("Source is not an application descriptor");
            }

            // check version
            if (new Version(node.GetAttribute("xversion")) > new Version(1, 0, 0))
            {
                throw new AbortInstallationException("Application descriptor is of an incorrect version");
            }

            string          name = node.GetAttribute("name");
            Guid            id   = new Guid(node.GetAttribute("id"));
            string          rootComponentName = node.GetAttribute("root");
            DocumentSupport apptype           = (DocumentSupport)Enum.Parse(typeof(DocumentSupport), node.GetAttribute("type"));
            string          friendlyName      = node.GetAttribute("friendly");

            List <ConfiguredComponent> defs = new List <ConfiguredComponent>();

            /** ok, construct **/
            ApplicationDesc app = new ApplicationDesc(id, apptype, name, friendlyName);

            foreach (XmlNode firstNode in node.ChildNodes)
            {
                if (firstNode.Name == "Components")
                {
                    /* load all components */
                    foreach (XmlNode componentNode in firstNode.ChildNodes)
                    {
                        if (componentNode.Name.StartsWith("#"))
                        {
                            continue;
                        }

                        if (componentNode.Name != "Component")
                        {
                            throw new AbortInstallationException("Application description is not well-formed. Only Component nodes are allowed in the Components section");
                        }

                        defs.Add(new ConfiguredComponent(componentNode));
                    }
                }
                if (firstNode.Name == "Bindings")
                {
                    foreach (XmlNode bindingNode in firstNode.ChildNodes)
                    {
                        if (bindingNode.Name != "Binding")
                        {
                            continue;
                        }

                        app.DefaultBindings[((XmlElement)bindingNode).GetAttribute("Type")] =
                            Array.ConvertAll <string, string>(
                                ((XmlElement)bindingNode).GetAttribute("Verbs").Split(','),
                                delegate(string s) { return(s.Trim()); });
                    }
                }
            }

            app.Components           = defs.ToArray();
            app.ApplicationComponent = rootComponentName;

            applicationDescriptor = app;
        }
        public static string GetParticipantInfo(IParticipant participant, string propertyname)
        {
            if (participant == null)
                return string.Empty;
            {
                if (String.IsNullOrEmpty(propertyname))
                    return String.Empty;

                propertyname = propertyname.ToLower();

                switch (propertyname)
                {
                    case "editurl":
                        var internalUrl = UrlResolver.Current.GetUrl(participant.EventPage);

                        UrlBuilder relativeUrl = new UrlBuilder(internalUrl);
                        Global.UrlRewriteProvider.ConvertToExternal(relativeUrl, null, System.Text.Encoding.UTF8);

                        string url = UriSupport.AbsoluteUrlBySettings(relativeUrl.ToString());
                        url = EPiServer.UriSupport.AddQueryString(url, "code",
                            participant.Code);
                        url = EPiServer.UriSupport.AddQueryString(url, "email",
                            participant.Email);
                        return url;

                    case "username":
                        return participant.Username;

                    case "registrationcode":
                        return participant.Code;

                    case "email":
                        return participant.Email;

                    case "price":
                        return participant.Price.ToString();

                    case "eventname":
                    case "coursename":
                        return DataFactory.Instance.Get<EventPageBase>(participant.EventPage).Name;

                    case "submitted":
                        return participant.DateSubmitted.ToString("yyyy-MM-dd HH:mm");

                    case "status":
                        return participant.AttendStatus.ToString();

                    case "fullname":
                        return GetParticipantInfo(participant, "FirstName") + " " +
                               GetParticipantInfo(participant, "LastName");

                    case "datestring":
                        return GetEventDates(participant.EventPage);

                    case "coursedatestring":
                        return string.Format(LocalizationService.Current.GetString("/attend/diploma/datetext"), GetEventDates(participant.EventPage));

                    default:
                        {
                            try
                            {
                                SerializableXmlDocument xmlDoc = new SerializableXmlDocument();
                                xmlDoc.LoadXml(participant.XForm);

                                foreach (XmlNode formNode in xmlDoc.SelectNodes("instance/*"))
                                {
                                    if (propertyname == formNode.Name.ToLower())
                                        return formNode.InnerText;
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        break;
                }

                return String.Empty;
            }
        }
        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;
        }
        public static string GetParticipantInfo(IParticipant participant, string propertyname)
        {
            if (participant == null)
            {
                return(string.Empty);
            }
            {
                if (String.IsNullOrEmpty(propertyname))
                {
                    return(String.Empty);
                }

                propertyname = propertyname.ToLower();

                switch (propertyname)
                {
                case "editurl":
                    var internalUrl = UrlResolver.Current.GetUrl(participant.EventPage);

                    UrlBuilder relativeUrl = new UrlBuilder(internalUrl);
                    Global.UrlRewriteProvider.ConvertToExternal(relativeUrl, null, System.Text.Encoding.UTF8);

                    string url = UriSupport.AbsoluteUrlBySettings(relativeUrl.ToString());
                    url = EPiServer.UriSupport.AddQueryString(url, "code",
                                                              participant.Code);
                    url = EPiServer.UriSupport.AddQueryString(url, "email",
                                                              participant.Email);
                    return(url);

                case "username":
                    return(participant.Username);

                case "registrationcode":
                    return(participant.Code);

                case "email":
                    return(participant.Email);

                case "price":
                    return(participant.Price.ToString());

                case "eventname":
                case "coursename":
                    return(DataFactory.Instance.Get <EventPageBase>(participant.EventPage).Name);

                case "submitted":
                    return(participant.DateSubmitted.ToString("yyyy-MM-dd HH:mm"));

                case "status":
                    return(participant.AttendStatus.ToString());

                case "fullname":
                    return(GetParticipantInfo(participant, "FirstName") + " " +
                           GetParticipantInfo(participant, "LastName"));

                case "datestring":
                    return(GetEventDates(participant.EventPage));

                case "coursedatestring":
                    return(string.Format(LocalizationService.Current.GetString("/attend/diploma/datetext"), GetEventDates(participant.EventPage)));

                default:
                {
                    try
                    {
                        SerializableXmlDocument xmlDoc = new SerializableXmlDocument();
                        xmlDoc.LoadXml(participant.XForm);

                        foreach (XmlNode formNode in xmlDoc.SelectNodes("instance/*"))
                        {
                            if (propertyname == formNode.Name.Replace('_', ' ').ToLower())
                            {
                                return(formNode.InnerText);
                            }
                        }
                        foreach (XmlNode formNode in xmlDoc.SelectNodes("FormData/*"))
                        {
                            if (propertyname == formNode.Name.ToLower())
                            {
                                return(formNode.InnerText);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                break;
                }

                return(String.Empty);
            }
        }
示例#12
0
        private void CacheDeserialization()
        {
            Child.InstallEnvironment = environment;
            SerializableXmlDocument doc = Child.OpenForReading <SerializableXmlDocument>().Object;

            doc.Normalize();

            XmlElement node = doc.FirstChild.NextSibling as XmlElement;

            // assert root node
            if (node.Name != "Library")
            {
                throw new AbortInstallationException("Source is not a library descriptor");
            }

            // check version
            if (new Version(node.GetAttribute("xversion")) > new Version(1, 0, 0))
            {
                throw new AbortInstallationException("Application descriptor is of an incorrect version");
            }

            string name = node.GetAttribute("name");
            // Guid id = new Guid(node.GetAttribute("id"));
            // string rootComponentName = node.GetAttribute("root");
            // ApplicationType apptype = (ApplicationType)Enum.Parse(typeof(ApplicationType), node.GetAttribute("type"));
            // string friendlyName = node.GetAttribute("friendly");

            List <ConfiguredComponent> defs = new List <ConfiguredComponent>();

            foreach (XmlNode firstNode in node.ChildNodes)
            {
                if (firstNode.Name == "Components")
                {
                    /* load all components */
                    foreach (XmlNode componentNode in firstNode.ChildNodes)
                    {
                        if (componentNode.Name.StartsWith("#"))
                        {
                            continue;
                        }

                        if (componentNode.Name != "Component")
                        {
                            throw new AbortInstallationException(
                                      String.Format(
                                          "Library description is not well-formed. Only Component nodes are allowed in the Components section. Found '{0}' instead",
                                          componentNode.Name));
                        }

                        defs.Add(new ConfiguredComponent(componentNode));
                    }
                }
            }

            /** ok, construct **/
            LibraryDesc lib = new LibraryDesc();

            lib.Components = defs.ToArray();

            applicationDescriptor = lib;
        }