예제 #1
0
        protected void TransferMediaItemBlob(Item source, Item destination, bool processChildren, ref long count)
        {
            Assert.IsNotNull(source, "source is null");
            Assert.IsNotNull(destination, "destination is null");

            count++;
            Logger.Log("Progress-", $"Processing \"{source.Paths.FullPath}\" - {DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}");
            foreach (Field field in source.Fields)
            {
                if (field.IsBlobField)
                {
                    var str = field.Value;
                    if (str.Length > 38)
                    {
                        str = str.Substring(0, 38);
                    }
                    var guid = MainUtil.GetGuid(str, Guid.Empty);
                    if (!(guid == Guid.Empty))
                    {
                        var blobStream = ItemManager.GetBlobStream(guid, ProxyManager.GetRealDatabase(source));
                        if (blobStream != null)
                        {
                            using (blobStream)
                            {
                                ItemManager.SetBlobStream(blobStream, guid, ProxyManager.GetRealDatabase(destination));
                            }
                        }
                    }
                }
            }

            if (Sitecore.Context.Job != null)
            {
                Sitecore.Context.Job.Status.Processed = count;
                Sitecore.Context.Job.Status.Messages.Add($"Processed media item {count}.");
            }

            if (processChildren)
            {
                foreach (Item child in source.Children)
                {
                    if (child != null)
                    {
                        TransferMediaItemBlob(child, destination, true, ref count);
                    }
                }
            }
        }
예제 #2
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            ListString list = new ListString(args.Parameters["entryids"]);

            if (args.IsPostBack)
            {
                if (args.HasResult && args.Result == "yes")
                {
                    if (list.Items.Any())
                    {
                        foreach (string id in list.Items)
                        {
                            Guid entryId = MainUtil.GetGuid(id, Guid.Empty);

                            if (entryId != Guid.Empty)
                            {
                                RedirectManager.DeleteRedirect(entryId);
                            }
                        }

                        Client.AjaxScriptManager.Dispatch("redirects:refresh");
                    }
                }
            }
            else
            {
                if (list.Any())
                {
                    if (list.Count == 1)
                    {
                        SheerResponse.Confirm(Translate.Text("Are you sure you want to delete this redirect?"));
                    }
                    else
                    {
                        SheerResponse.Confirm(Translate.Text("Are you sure you want to delete these {0} redirects?", new object[] { list.Count }));
                    }
                    args.WaitForPostBack();
                }
            }
        }
예제 #3
0
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            ClientPipelineArgs args = new ClientPipelineArgs();

            ListString list = new ListString(context.Parameters["entryids"]);

            bool isNew = context.Parameters["new"] == "1";

            if (list.Items.Any() && !isNew)
            {
                Guid entryId = MainUtil.GetGuid(list.Items.FirstOrDefault(), Guid.Empty);
                if (entryId != Guid.Empty)
                {
                    RedirectEntry entry = RedirectManager.GetRedirect(entryId);
                    if (entry != null)
                    {
                        args.Parameters["entryid"]     = entryId.ToString();
                        args.Parameters["oldpath"]     = entry.OldPath;
                        args.Parameters["itemid"]      = entry.ItemID.ToString();
                        args.Parameters["querystring"] = entry.QueryString;
                        args.Parameters["site"]        = entry.Site;
                    }
                }
            }


            ContinuationManager current = ContinuationManager.Current;

            if (current != null)
            {
                current.Start(this, "Run", args);
            }
            else
            {
                Context.ClientPage.Start(this, "Run", args);
            }
        }
예제 #4
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (args.IsPostBack)
            {
                if (args.HasResult && args.Result != "undefined")
                {
                    UrlString results = new UrlString(args.Result);
                    Database  db      = Sitecore.Context.ContentDatabase;

                    Guid   entryId     = MainUtil.GetGuid(args.Parameters["entryid"], Guid.Empty);
                    Item   item        = db.GetItem(HttpUtility.UrlDecode(results["itemid"]));
                    string oldPath     = HttpUtility.UrlDecode(results["oldpath"]);
                    string querystring = HttpUtility.UrlDecode(results["querystring"]);
                    string site        = HttpUtility.UrlDecode(results["site"]);

                    if (item != null)
                    {
                        string siteName = site;// RedirectManager.ResolveSiteName(item);

                        if (entryId != Guid.Empty)
                        {
                            RedirectEntry entry = RedirectManager.GetRedirect(entryId);
                            if (entry != null)
                            {
                                entry.ItemID      = item.ID.ToGuid();
                                entry.OldPath     = oldPath;
                                entry.QueryString = querystring;
                                entry.Site        = siteName;

                                RedirectManager.UpdateRedirect(entry);
                            }
                        }
                        else
                        {
                            RedirectManager.CreateRedirect(siteName, oldPath, item.ID, querystring);
                        }
                    }

                    Client.AjaxScriptManager.Dispatch("redirects:refresh");
                }
            }
            else
            {
                UrlString url = new UrlString(UIUtil.GetUri("control:EditRedirectForm"));

                if (!string.IsNullOrEmpty(args.Parameters["itemid"]))
                {
                    url["itemid"] = args.Parameters["itemid"];
                }
                if (!string.IsNullOrEmpty(args.Parameters["oldpath"]))
                {
                    url["oldpath"] = args.Parameters["oldpath"];
                }
                if (!string.IsNullOrEmpty(args.Parameters["querystring"]))
                {
                    url["querystring"] = args.Parameters["querystring"];
                }
                if (!string.IsNullOrEmpty(args.Parameters["site"]))
                {
                    url["site"] = args.Parameters["site"];
                }


                SheerResponse.ShowModalDialog(url.ToString(), true);
                args.WaitForPostBack();
            }
        }