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


C# Media.Move方法代码示例

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


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

示例1: HandleDocumentMoveOrCopy

        private void HandleDocumentMoveOrCopy()
        {
            if (helper.Request("copyTo") != "" && helper.Request("id") != "")
            {
                // Check if the current node is allowed at new position
                var nodeAllowed = false;

                var currentNode = new cms.businesslogic.Content(int.Parse(helper.Request("id")));

				var newNode = new cms.businesslogic.Content(int.Parse(helper.Request("copyTo")));

                // Check on contenttypes
                if (int.Parse(helper.Request("copyTo")) == -1)
                {
                    nodeAllowed = true;
                }
                else
                {
                    if (newNode.ContentType.AllowedChildContentTypeIDs.Where(c => c == currentNode.ContentType.Id).Any())
                    {
                        nodeAllowed = true;
                    }

                    if (nodeAllowed == false)
                    {
                        feedback.Text = ui.Text("moveOrCopy", "notAllowedByContentType", base.getUser());
                        feedback.type = uicontrols.Feedback.feedbacktype.error;
                    }
                    else
                    {
                        // Check on paths
                        if ((string.Format(",{0},", newNode.Path)).IndexOf(string.Format(",{0},", currentNode.Id)) > -1)
                        {
                            nodeAllowed = false;
                            feedback.Text = ui.Text("moveOrCopy", "notAllowedByPath", base.getUser());
                            feedback.type = uicontrols.Feedback.feedbacktype.error;
                        }
                    }
                }

                if (nodeAllowed)
                {
                    pane_form.Visible = false;
                    pane_form_notice.Visible = false;
                    panel_buttons.Visible = false;

                    var newNodeCaption = newNode.Id == -1 ? ui.Text(CurrentApp) : newNode.Text;

                    string[] nodes = { currentNode.Text, newNodeCaption };

                    if (Request["mode"] == "cut")
                    {
                        if (CurrentApp == "content")
                        {
                            //PPH changed this to document instead of cmsNode to handle republishing.
                            var documentId = int.Parse(helper.Request("id"));
                            var document = new Document(documentId);
                            document.Move(int.Parse(helper.Request("copyTo")));
                            library.RefreshContent();
                        }
                        else
                        {
                            var media = new Media(int.Parse(UmbracoContext.Current.Request["id"]));
                            media.Move(int.Parse(UmbracoContext.Current.Request["copyTo"]));
                            media = new Media(int.Parse(UmbracoContext.Current.Request["id"]));
                            media.XmlGenerate(new XmlDocument());
                            library.ClearLibraryCacheForMedia(media.Id);
                        }

                        feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = uicontrols.Feedback.feedbacktype.success;

                        // refresh tree
                        ClientTools.MoveNode(currentNode.Id.ToString(), newNode.Path);
                    }
                    else
                    {
                        var document = new Document(int.Parse(helper.Request("id")));
                        document.Copy(int.Parse(helper.Request("copyTo")), this.getUser(), RelateDocuments.Checked);
                        feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = uicontrols.Feedback.feedbacktype.success;
                        ClientTools.CopyNode(currentNode.Id.ToString(), newNode.Path);
                    }
                }
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:86,代码来源:moveOrCopy.aspx.cs

示例2: HandleDocumentMoveOrCopy

        private void HandleDocumentMoveOrCopy() 
		{
			if (helper.Request("copyTo") != "" && helper.Request("id") != "") 
			{
				// Check if the current node is allowed at new position
				bool nodeAllowed = false;

				cms.businesslogic.Content currentNode = new cms.businesslogic.Content(int.Parse(helper.Request("id")));
                int oldParent = -1;
                if (currentNode.Level > 1)
                   oldParent = currentNode.Parent.Id;
				cms.businesslogic.Content newNode = new cms.businesslogic.Content(int.Parse(helper.Request("copyTo")));

				// Check on contenttypes
				if (int.Parse(helper.Request("copyTo")) == -1)
					nodeAllowed = true;
				else 
				{
					foreach (int i in newNode.ContentType.AllowedChildContentTypeIDs.ToList())
						if (i == currentNode.ContentType.Id) 
						{
							nodeAllowed = true;
							break;
						}
                    if (!nodeAllowed) {
                        feedback.Text = ui.Text("moveOrCopy", "notAllowedByContentType", base.getUser());
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
                    } else {
                        // Check on paths
                        if (((string)("," + newNode.Path + ",")).IndexOf("," + currentNode.Id + ",") > -1) {
                            nodeAllowed = false;
                            feedback.Text = ui.Text("moveOrCopy", "notAllowedByPath", base.getUser());
                            feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
                        }
                    }
				}


				if (nodeAllowed) 
				{
                    pane_form.Visible = false;
                    pane_form_notice.Visible = false;
                    panel_buttons.Visible = false;

                    string newNodeCaption = newNode.Id == -1 ? ui.Text(helper.Request("app")) : newNode.Text;

                    string[] nodes = {currentNode.Text, newNodeCaption };

                    if (UmbracoContext.Current.Request["mode"] == "cut")
                    {
                        if (UmbracoContext.Current.Request["app"] == "content")
                        {
                            //PPH changed this to document instead of cmsNode to handle republishing.
                            cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
                            d.Move(int.Parse(helper.Request("copyTo")));
                            if (d.Published)
                            {
                                d.Publish(new umbraco.BusinessLogic.User(0));
                                //using library.publish to support load balancing.
                                //umbraco.library.PublishSingleNode(d.Id);
                                umbraco.library.UpdateDocumentCache(d.Id);

                                //PPH added handling of load balanced moving of multiple nodes...
                                if (d.HasChildren)
                                {
                                    handleChildNodes(d);
                                }

                                //Using the general Refresh content method instead as it supports load balancing. 
                                //we only need to do this if the node is actually published.
                                library.RefreshContent();
                            }
                            d.Save(); //stub to save stuff to the db.
                        }
                        else
                        {
                            Media m = new Media(int.Parse(UmbracoContext.Current.Request["id"]));
                            m.Move(int.Parse(UmbracoContext.Current.Request["copyTo"]));
                            m.XmlGenerate(new XmlDocument());
                            library.ClearLibraryCacheForMedia(m.Id);
                        }                                 

                        feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;

                        // refresh tree
						ClientTools.MoveNode(currentNode.Id.ToString(), newNode.Path);

                    } 
					else 
					{
						cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
						d.Copy(int.Parse(helper.Request("copyTo")), this.getUser(), RelateDocuments.Checked);
						feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
						ClientTools.CopyNode(currentNode.Id.ToString(), newNode.Path);
                    }
				} 
			}
		}
开发者ID:elrute,项目名称:Triphulcas,代码行数:100,代码来源:moveOrCopy.aspx.cs


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