+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Argument Exception for WorkflowManager.MessageWorkflow

Argument Exception for WorkflowManager.MessageWorkflow

2 posts, 0 answered
  1. Anju
    Anju avatar
    19 posts
    Registered:
    22 Jul 2014
    22 May 2015
    Link to this post

    Hi,

     I was trying to upload image files to album usign API in sitefinity. It was working fine for me. Now when i was trying on it again it is throwing the following exception:

    An exception of type 'System.ArgumentException' occurred in Telerik.Sitefinity.dll but was not handled in user code

    Additional information: Id cannot be Empty Guid

     

    The following is the code which i face the issue:

    public Guid CreateNewsItemAlbum(string parentAlbumTitle, string imageTitle, Stream imageStream, string imageExtension)
            {
                //gets an instance of the LibrariesManager
                var manager = LibrariesManager.GetManager();
                LibrariesManager.GetManager().Provider.SuppressSecurityChecks = true;

                var childFolderTitle = DateTime.Now.Date.ToString("MMM dd yyyy");

                //creates an image album(library)
                var parentAlbum = manager.GetAlbums().Where(a => a.Title == parentAlbumTitle).FirstOrDefault();
                if (parentAlbum == null)
                {
                    var imagesAlbum = manager.CreateAlbum();
                    imagesAlbum.Title = parentAlbumTitle;

                    var url = Regex.Replace(parentAlbumTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                    imagesAlbum.UrlName = url;
                    imagesAlbum.ItemDefaultUrl = "/" + url;
                    imagesAlbum.Urls.Add(new LibraryUrlData
                    {
                        Id = Guid.NewGuid(),
                        Url = imagesAlbum.ItemDefaultUrl,
                        ApplicationName = manager.Provider.ApplicationName
                    });
                    manager.SaveChanges();

                    CreateFolderInAlbum(imagesAlbum, childFolderTitle, "Child folder title if parent album is null");
                }
                else
                {
                    CreateFolderInAlbum(parentAlbum, childFolderTitle, "Child folder title if parent album is not null");
                }
                Guid id  = Guid.NewGuid();
                UploadAlbumImages(parentAlbumTitle, childFolderTitle, imageTitle, imageStream, imageExtension, id);

                //Publish the Albums item. The live version acquires new ID.
                var bag = new Dictionary<string, string>();
                WorkflowManager.GetManager().Provider.SuppressSecurityChecks = true;
                bag.Add("ContentType", typeof(Telerik.Sitefinity.Libraries.Model.Image).FullName);
                var x = WorkflowManager.MessageWorkflow(id, typeof(Telerik.Sitefinity.Libraries.Model.Image), null, "Publish", false, bag);
                return id;
            }//gets an instance of the LibrariesManager
                var manager = LibrariesManager.GetManager();
                LibrariesManager.GetManager().Provider.SuppressSecurityChecks = true;

                var childFolderTitle = DateTime.Now.Date.ToString("MMM dd yyyy");

                //creates an image album(library)
                var parentAlbum = manager.GetAlbums().Where(a => a.Title == parentAlbumTitle).FirstOrDefault();
                if (parentAlbum == null)
                {
                    var imagesAlbum = manager.CreateAlbum();
                    imagesAlbum.Title = parentAlbumTitle;

                    var url = Regex.Replace(parentAlbumTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                    imagesAlbum.UrlName = url;
                    imagesAlbum.ItemDefaultUrl = "/" + url;
                    imagesAlbum.Urls.Add(new LibraryUrlData
                    {
                        Id = Guid.NewGuid(),
                        Url = imagesAlbum.ItemDefaultUrl,
                        ApplicationName = manager.Provider.ApplicationName
                    });
                    manager.SaveChanges();

                    CreateFolderInAlbum(imagesAlbum, childFolderTitle, "Child folder title if parent album is null");
                }
                else
                {
                    CreateFolderInAlbum(parentAlbum, childFolderTitle, "Child folder title if parent album is not null");
                }
                Guid id  = Guid.NewGuid();
                UploadAlbumImages(parentAlbumTitle, childFolderTitle, imageTitle, imageStream, imageExtension, id);

                //Publish the Albums item. The live version acquires new ID.
                var bag = new Dictionary<string, string>();
                WorkflowManager.GetManager().Provider.SuppressSecurityChecks = true;
                bag.Add("ContentType", typeof(Telerik.Sitefinity.Libraries.Model.Image).FullName);
                var x = WorkflowManager.MessageWorkflow(id, typeof(Telerik.Sitefinity.Libraries.Model.Image), null, "Publish", false, bag);
                return id;​

     }

    Please find the attached screenshot of the exception.

    I am not sure whats going wrong. Any body faced simlar issues ? 

    Thanks, 

    Anju Raman

     

     

  2. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    02 Dec 2016
    26 May 2015
    Link to this post
    Hi Anju,

    It seems that some Id is coming null on your code. I would like kindly suggest you to put a breakpoint and determine where in what part of the code is the exception happening.

    Best Regards,
    Junior Dominguez
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered