当前位置: 首页>>代码示例>>C#>>正文


C# IItem.GetHostUrl方法代码示例

本文整理汇总了C#中IItem.GetHostUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IItem.GetHostUrl方法的具体用法?C# IItem.GetHostUrl怎么用?C# IItem.GetHostUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IItem的用法示例。


在下文中一共展示了IItem.GetHostUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyItemCallback

        public void CopyItemCallback(IItem sourceItem, IItem destinationParentItem, IItem destinationItem)
        {
            try
            {
                if (_PluginOptions[0].Value == "False")
                    return;
                // No template for this item, so it is probably a template itself
                if ((sourceItem.Templates == null) || (sourceItem.Templates[0] == null))
                    return;

                Uri hostUri = new Uri(sourceItem.GetHostUrl());
                string sHost = hostUri.Scheme + "://" + hostUri.Host;

                IItem tmpItem = sourceItem;
                while (tmpItem != null)
                {
                    if ((tmpItem.Templates[0].Name.ToLower() == "fff.departmentwebsite") ||
                        (tmpItem.Templates[0].Name.ToLower() == "fff.industrysectorclubwebsite"))
                    {
                        // Try to get real gallery folder ID
                        IField field = Util.GetFieldByName("GalleryFolderID", tmpItem.Fields);
                        // We are still at the same department, _sLastDepartmentName is still valid
                        if (field.Content.ToUpper() == _sLastDepartmentID)
                            break;

                        // Default value
                        _sLastDepartmentName = tmpItem.Name;

                        // Try to get real gallery folder name
                        IItem mediaItem = null;
                        try
                        { mediaItem = sourceItem.GetItem(field.Content.ToUpper()); }
                        catch { }
                        if (mediaItem != null)
                        {
                            _sLastDepartmentName = mediaItem.Name;
                            _sLastDepartmentID = "{" + mediaItem.ID.ToString().ToUpper() + "}";
                        }
                        break;
                    }
                    tmpItem = tmpItem.Parent;
                }

                foreach (IField field in destinationItem.Fields)
                {
                    string sContent = field.Content.ToLower();

                    if ((sContent.IndexOf("<file") > -1) || (sContent.IndexOf("&lt;file ") > -1))
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(field.Content);
                        XmlNodeList files = doc.SelectNodes("//file");
                        foreach (XmlNode file in files)
                        {
                            // empty file node?
                            if ((file.Attributes["url"] == null) || (file.Attributes["title"] == null))
                                continue;

                            // Content is already in gallery format
                            if (file.Attributes["galleryformat"] != null)
                                continue;

                            string sUrl = file.Attributes["url"].Value;
                            string sTitle = file.Attributes["title"].Value;
                            string sMediaID = file.Attributes["mediaid"].Value;

                            // Content is already in gallery format, since it contains destination host
                            if (sUrl.Contains(_PluginOptions[1].Value))
                                continue;

                            //                        IItem mediaItem = sourceItem.GetItem(sMediaID);
                            int iFileSize = 0;
                            string sResult = CopyFile(sHost + sUrl, sTitle, out iFileSize);
                            if (sResult != null)
                            {
                                file.Attributes["mediaid"].Value = sResult;
                                file.Attributes["url"].Value = _PluginOptions[1].Value + string.Format("/Image.ashx?File={0}", System.Web.HttpUtility.UrlEncode(sResult));
                                file.Attributes.Append(doc.CreateAttribute("size"));
                                file.Attributes["size"].Value = iFileSize.ToString();
                            }
                        }
                        // If the content doesn't have <files> root, the doc object inserts <xml> root
                        if (doc.FirstChild.Name == "files")
                            field.Content = doc.OuterXml;
                        else
                            field.Content = doc.InnerXml;
                    }
                    // Convert filestorage fields
                    else if (sContent.IndexOf("/sitecore%20modules/filestorage/default.aspx?fileid=") > -1)
                    {
                        XmlDocument doc = Sgml.SgmlUtil.ParseHtml(sContent);
                        XmlNodeList linkNodes = doc.SelectNodes("//a");
                        foreach (XmlNode node in linkNodes)
                        {
                            string sUrl = Util.GetAttributeValue(node.Attributes["href"]);
                            string sTitle = Util.GetAttributeValue(node.Attributes["sc_text"]);
                            string sc_linktype = Util.GetAttributeValue(node.Attributes["sc_linktype"]);
                            string sc_url = Util.GetAttributeValue(node.Attributes["sc_url"]);
                            string sTarget = Util.GetAttributeValue(node.Attributes["target"]);
                            if ((sc_linktype == "media") ||
//.........这里部分代码省略.........
开发者ID:Cabana,项目名称:CMSConverter,代码行数:101,代码来源:FilestorageConversionPlugin.cs

示例2: btnCopyToRight_Click

        private void btnCopyToRight_Click(object sender, EventArgs e)
        {
            if (rightTreeView.SelectedNode == null)
            {
                MessageBox.Show("Select destination node in right window", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                return;
            }

            if (leftTreeView.SelectedNode == null)
            {
                MessageBox.Show("Select source node in left window", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
                return;
            }

            /*
            IItem destItem = rightTreeView.SelectedNode.Tag as IItem;
            IItem srcItem = leftTreeView.SelectedNode.Tag as IItem;
            destItem.CopyTo(srcItem, true);
            */

            _srcItem = leftTreeView.SelectedNode.Tag as IItem;
            _destItem = rightTreeView.SelectedNode.Tag as IItem;
            _destinationNode = rightTreeView.SelectedNode;

            CopyOptions CopyOptionsForm = new CopyOptions();
            string[] sLanguages = _srcItem.GetLanguages();
            foreach (string sLang in sLanguages)
            {
                CopyOptionsForm.comboFromLanguage.Items.Add(sLang);
            }

            sLanguages = _destItem.GetLanguages();
            foreach (string sLang in sLanguages)
            {
                CopyOptionsForm.comboToLanguage.Items.Add(sLang);
            }
            CopyOptionsForm.comboToLanguage.SelectedIndex = 0;
            CopyOptionsForm.lblToPath.Text = "(" + new Uri(_destItem.GetHostUrl()).Host + ")" + _destItem.Path;

            // Setting this AFTER the destination, enables autoselect of correct destination language
            CopyOptionsForm.comboFromLanguage.SelectedIndex = 0;
            CopyOptionsForm.lblFromPath.Text = "(" + new Uri(_srcItem.GetHostUrl()).Host + ")" + _srcItem.Path;

            // Plugins
            CopyOptionsForm._itemCopyPlugins = _itemCopyPlugins;

            // Show Copyoptions
            if (CopyOptionsForm.ShowDialog(this) == DialogResult.Cancel)
                return;

            // Get copyOptions result
            _srcItem.Options.Language = CopyOptionsForm.comboFromLanguage.Text;
            _destItem.Options.Language = CopyOptionsForm.comboToLanguage.Text;
            _destItem.Options.CopyItem = CopyItem;
            if (CopyOptionsForm.rbOverwrite.Checked)
                _destItem.Options.CopyOperation = CopyOperations.Overwrite;
            else if (CopyOptionsForm.rbSkipExisting.Checked)
                _destItem.Options.CopyOperation = CopyOperations.SkipExisting;
            else if (CopyOptionsForm.rbCreateNewItemIDs.Checked)
                _destItem.Options.CopyOperation = CopyOperations.GenerateNewItemIDs;
            else if (CopyOptionsForm.rbUseNames.Checked)
                _destItem.Options.CopyOperation = CopyOperations.UseNames;
            _destItem.Options.RecursiveOperation = CopyOptionsForm.cbRecursive.Checked;

            //            _srcItem.Options.Database = CopyOptionsForm.tbFromDatabase.Text;
            //            _destItem.Options.Database = CopyOptionsForm.tbToDatabase.Text;

            // Security settings
            _srcItem.Options.CopySecuritySettings = CopyOptionsForm.cbCopySecurity.Checked;
            _destItem.Options.CopySecuritySettings = CopyOptionsForm.cbCopySecurity.Checked;
            _destItem.Options.DefaultSecurityDomain = CopyOptionsForm.tbSecurityDomain.Text;
            _destItem.Options.RootRole = CopyOptionsForm.tbRootRole.Text;
            _destItem.Options.SetItemRightsExplicitly = CopyOptionsForm.cbSetItemRightsExplicitly.Checked;

            Util.backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgument("copy", null, null, this));

            _progressForm = new ProgressForm();
            _progressForm.ShowDialog(this);
        }
开发者ID:Cabana,项目名称:CMSConverter,代码行数:79,代码来源:Form1.cs


注:本文中的IItem.GetHostUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。