コード例 #1
0
        private void WriteToModelItemDataProperty(string propertyName, string propertyValue)
        {
            string xmlConfig = _webActivity.XMLConfiguration;

            UnlimitedObject d = UnlimitedObject.GetStringXmlDataAsUnlimitedObject(xmlConfig);

            d.GetElement(propertyName).SetValue(propertyValue);

            _webActivity.XMLConfiguration = d.XmlString;
        }
コード例 #2
0
        private void SetConfigFragment(string webPartElementName, dynamic xmlConfiguration)
        {
            string          configuration = WebActivity.XMLConfiguration;
            UnlimitedObject configData    = UnlimitedObject.GetStringXmlDataAsUnlimitedObject(configuration);

            if (configData.ElementExists(webPartElementName.ToLower()))
            {
                configData.RemoveElementsByTagName(webPartElementName.ToLower());
            }

            configData.CreateElement(webPartElementName.ToLower()).Add(xmlConfiguration);

            //Write xml configuration to the layout cell
            dynamic layoutXml = new UnlimitedObject(webPartElementName.ToLower());

            layoutXml.Add(xmlConfiguration);
            SelectedLayoutObject.XmlConfiguration = layoutXml.XmlString;


            _webActivity.XMLConfiguration = configData.XmlString;
            Deploy();
        }
コード例 #3
0
        public void UpdateModelItem()
        {
            if (!string.IsNullOrEmpty(Html) && _webActivity != null && _webActivity.ResourceModel != null && _webActivity.ResourceModel.Environment != null)
            {
                int rows = 0;

                UnlimitedObject tags = new UnlimitedObject();

                try
                {
                    tags = UnlimitedObject.GetStringXmlDataAsUnlimitedObject(Html.ToLower());
                }
                catch { IsValidMarkup = false; return; }

                if (tags.HasError)
                {
                    IsValidMarkup = false;
                    return;
                }
                else
                {
                    IsValidMarkup = true;
                }

                var tagItems = tags.GetAllElements("dev2html");

                bool copyToPrevious = false;

                if (lastGood == null)
                {
                    copyToPrevious = true;
                }
                else
                {
                    previous = new ILayoutObjectViewModel[lastGood.Length];
                    lastGood.CopyTo(previous, 0);
                }

                _layoutObjects.Clear();

                foreach (dynamic tag in tagItems)
                {
                    IResourceModel res = null;

                    string name     = null;
                    string type     = null;
                    string iconpath = null;

                    if (tag.name is string)
                    {
                        name = tag.name;
                    }

                    if (tag.type is string)
                    {
                        type = tag.type;
                        res  = _webActivity.ResourceModel.Environment.Resources.All().FirstOrDefault(c => c.ResourceName.Equals(type, StringComparison.InvariantCultureIgnoreCase));
                        if (res != null)
                        {
                            iconpath = res.IconPath;
                        }
                    }

                    var exclusions = new List <string>()
                    {
                        "form", "meta", "pagetitle"
                    };
                    if (!exclusions.Contains(type.ToLower()))
                    {
                        if (string.IsNullOrEmpty(name))
                        {
                            IsValidMarkup = false;
                            return;
                        }

                        if (string.IsNullOrEmpty(type))
                        {
                            IsValidMarkup = false;
                            return;
                        }

                        if (string.IsNullOrEmpty(StringResources.Website_Supported_Webparts))
                        {
                            throw new Exception(StringResources.Error_Supported_Webparts_Not_Set);
                        }

                        List <string> inclusions = StringResources.Website_Supported_Webparts.Split(new char[] { ',' }).ToList();
                        if (!inclusions.Contains(type.ToLower()))
                        {
                            IsValidMarkup = false;
                            return;
                        }

                        var newobject = LayoutObjectViewModelFactory.CreateLayoutObject(type, name, iconpath, GetConfigFragment(name));

                        //Check if another webpart with the same name - not type - exists
                        //If so then we want to mark the website html as invalid
                        //as we don't allow multiple parts with the same name
                        var match = _layoutObjects.Any(c => c.WebpartServiceDisplayName.Equals(newobject.WebpartServiceDisplayName, StringComparison.InvariantCultureIgnoreCase));

                        if (match)
                        {
                            IsValidMarkup = false;
                            return;
                        }

                        IsValidMarkup = true;
                        _layoutObjects.Add(newobject);
                        _webActivity.Html = Html;
                        rows++;
                    }
                }

                if (_layoutObjects.Count > 0)
                {
                    lastGood = new ILayoutObjectViewModel[_layoutObjects.Count];
                    _layoutObjects.CopyTo(lastGood, 0);
                }

                //Initial load only
                if (copyToPrevious)
                {
                    if (lastGood != null)
                    {
                        previous = new ILayoutObjectViewModel[lastGood.Length];
                        lastGood.CopyTo(previous, 0);
                    }
                    copyToPrevious = false;
                }
                if (lastGood != null)
                {
                    CompareAndRemoveDeleted(lastGood.ToList().ToObservableCollection(), previous.ToObservableCollection());
                }
                // Update the HTML markup
                if (IsValidMarkup)
                {
                    _webActivity.Html = Html;
                }
                Rows = rows;
            }
        }
コード例 #4
0
        private string ReadFromModelItemDataProperty(string propertyName)
        {
            dynamic data = UnlimitedObject.GetStringXmlDataAsUnlimitedObject(_webActivity.XMLConfiguration);

            return(data.GetValue(propertyName));
        }