I'm trying to access my umbraco installation via a console application that I want to write to do various scheduled tasks. However I'm hitting an issue relating to the Perplex forms package that's installed. When the application starts I get the following error....
2018-04-05 16:53:44,731 [P6500/D1/T1] ERROR Umbraco.Core.CoreBootManager - An error occurred running OnApplicationStarting for handler PerplexUmbraco.Forms.Code.UmbracoEvents
System.ArgumentNullException: Value cannot be null.
Parameter name: path
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path)
at PerplexUmbraco.Forms.Code.Configuration.PerplexUmbracoFormsConfig.CreateIfNotExists()
at PerplexUmbraco.Forms.Code.UmbracoEvents.ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
at Umbraco.Core.ApplicationEventHandler.OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
at Umbraco.Core.CoreBootManager.
I'm running the application from the bin directory and I've created App_Plugins\PerplexUmbracoForms\PerplexUmbracoForms.config in the bin directory but looking at the error it appears the path variable is null as if PerplexForms is unable to read its constants.
Has anyone managed to access their umbraco site from an external application when using perplex forms?
The code for it is executing HostingEnvironment.MapPath("~/App_Plugins/PerplexUmbracoForms/PerplexUmbracoForms.config"), I suppose in a Console environment this yields null. As a quick fix you can build the solution yourself and add a null check there (source here). I can look into this later as well, but unfortunately not right now.
However, I wonder why your console application is executing the UmbracoApplicationHandler classes at all. Couldn't you perhaps communicate using e.g. calls to API controllers, so your Console Application can be kept separate and does not need to execute any Umbraco startup code (like it apparently is doing?).
Also, if it's a separate application, can't you simply remove Perplex.Umbraco.Forms.dll from the bin folder, which adds the application startup code?
Can't provide much more support at the moment, will check back at a later day, good luck!
Thanks for the reply. The separate app I was writing was to delete form submissions from the umbraco backend. In our Umbraco 6/Contour setup I delete the submission in the workflow but in Umbraco 7/UmbracoForms if I delete the submission in the workflow, it throws an error when it attempts auto approve the record which now no longer exists.
So I was going to write a service that among other things takes care of the housekeeping of the records in the backend. So instead of plugging in to the umbraco application I decided to delete the record directly from the umbraco database, is there any problem doing it this way? It appears to work fine.
private int DeleteRecord(string recordID, string connString)
{
int valueToReturn = 0;
try
{
int subID = -1;
SqlConnection sconn = new SqlConnection(connString);
SqlCommand scomm = new SqlCommand("", sconn);
SqlDataReader sdr;
sconn.Open();
//Get Record ID
scomm.Parameters.AddWithValue("@subID", recordID);
scomm.CommandText = "select id from ufrecords where uniqueid=@subID";
sdr = scomm.ExecuteReader();
if (sdr.HasRows)
{
while(sdr.Read())
{
subID = sdr.GetInt32(0);
}
}
sdr.Close();
if (subID>=0)
{
//Record to delete
//delete values
scomm.Parameters.Clear();
scomm.Parameters.AddWithValue("@subID", subID);
scomm.CommandText = "delete from ufrecorddatabit where [key] in(select [key] from ufrecordfields where record=@subID)";
scomm.ExecuteNonQuery();
scomm.CommandText = "delete from ufrecorddatadatetime where [key] in(select [key] from ufrecordfields where record=@subID)";
scomm.ExecuteNonQuery();
scomm.CommandText = "delete from ufrecorddatainteger where [key] in(select [key] from ufrecordfields where record=@subID)";
scomm.ExecuteNonQuery();
scomm.CommandText = "delete from ufrecorddatalongstring where [key] in(select [key] from ufrecordfields where record=@subID)";
scomm.ExecuteNonQuery();
scomm.CommandText = "delete from ufrecorddatastring where [key] in(select [key] from ufrecordfields where record=@subID)";
scomm.ExecuteNonQuery();
//delete recordfields
scomm.CommandText = "delete from ufrecordfields where record=@subID";
scomm.ExecuteNonQuery();
//delete record
scomm.CommandText = "delete from ufrecords where id=@subID";
scomm.ExecuteNonQuery();
valueToReturn = 1;
}
scomm.ExecuteNonQuery();
sconn.Close();
scomm = null;
sconn = null;
sdr = null;
}
catch(Exception ex)
{
valueToReturn = 2;
//Log error
//MessageBox.Show(ex.Message.ToString());
}
return valueToReturn;
}
I don't have experience with deleting Forms records directly from the database table, but I think this is probably fine. We also delete version history for content nodes by executing queries directly on the database and that does not cause issues.
Console Application when using Perplex Forms
Hi,
I'm trying to access my umbraco installation via a console application that I want to write to do various scheduled tasks. However I'm hitting an issue relating to the Perplex forms package that's installed. When the application starts I get the following error....
2018-04-05 16:53:44,731 [P6500/D1/T1] ERROR Umbraco.Core.CoreBootManager - An error occurred running OnApplicationStarting for handler PerplexUmbraco.Forms.Code.UmbracoEvents System.ArgumentNullException: Value cannot be null. Parameter name: path at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.StreamWriter..ctor(String path) at PerplexUmbraco.Forms.Code.Configuration.PerplexUmbracoFormsConfig.CreateIfNotExists() at PerplexUmbraco.Forms.Code.UmbracoEvents.ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) at Umbraco.Core.ApplicationEventHandler.OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) at Umbraco.Core.CoreBootManager.
I'm running the application from the bin directory and I've created App_Plugins\PerplexUmbracoForms\PerplexUmbracoForms.config in the bin directory but looking at the error it appears the path variable is null as if PerplexForms is unable to read its constants.
Has anyone managed to access their umbraco site from an external application when using perplex forms?
Thanks
Richy
Hi Richy,
The code for it is executing
HostingEnvironment.MapPath("~/App_Plugins/PerplexUmbracoForms/PerplexUmbracoForms.config")
, I suppose in a Console environment this yields null. As a quick fix you can build the solution yourself and add a null check there (source here). I can look into this later as well, but unfortunately not right now.However, I wonder why your console application is executing the UmbracoApplicationHandler classes at all. Couldn't you perhaps communicate using e.g. calls to API controllers, so your Console Application can be kept separate and does not need to execute any Umbraco startup code (like it apparently is doing?).
Also, if it's a separate application, can't you simply remove
Perplex.Umbraco.Forms.dll
from the bin folder, which adds the application startup code?Can't provide much more support at the moment, will check back at a later day, good luck!
Hi,
Thanks for the reply. The separate app I was writing was to delete form submissions from the umbraco backend. In our Umbraco 6/Contour setup I delete the submission in the workflow but in Umbraco 7/UmbracoForms if I delete the submission in the workflow, it throws an error when it attempts auto approve the record which now no longer exists.
So I was going to write a service that among other things takes care of the housekeeping of the records in the backend. So instead of plugging in to the umbraco application I decided to delete the record directly from the umbraco database, is there any problem doing it this way? It appears to work fine.
Hi Richy,
I don't have experience with deleting Forms records directly from the database table, but I think this is probably fine. We also delete version history for content nodes by executing queries directly on the database and that does not cause issues.
is working on a reply...