Argument Exception for WorkflowManager.MessageWorkflow
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
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