Plugin error message jiwa.  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Plugin error message jiwa.

Postby JuiceyBrucey » Tue Aug 29, 2023 4:48 pm

Version SR 16, 7.2.1
When trying to save the plugin, I get this error message.
Error message:
the type of namespace name 'jiwaSales' does not exist in the namespace 'JiwaFinancialsJiwa' are you missing an assembly referance?
Code: Select all
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using JiwaFinancials.Jiwa;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing;
using ServiceStack;
using ServiceStack.DataAnnotations;
using ServiceStack.Model;
using JiwaFinancials.Jiwa.JiwaServiceModel.Tables;
using ServiceStack.Auth;
using System.Linq;
using ServiceStack.OrmLite; // Db
using System.Configuration;


namespace JiwaFinancials.Jiwa.JiwaServiceModel
{
   public class RESTAPIPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaRESTAPIPlugin
   {
      public void Configure(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin, ServiceStack.ServiceStackHost  AppHost, Funq.Container Container, JiwaApplication.Manager JiwaApplicationManager)
      {         
         //System.Diagnostics.Debugger.Launch();
         //System.Diagnostics.Debugger.Break();
         AppHost.RegisterService<CustomServices>();
         //using InvoiceID from QO_Main table as id in ToDo (TD_Main) table
         AppHost.Routes.Add(typeof(InsertToDoRequest), "/Custom/InsertToDoRequest/{InvoiceID}/{MsgSubject}/{MsgBody}/{AssignTo}/", "GET", "Inserts a ToDo note associated with a quote to create an alert.", "");
      }
   }
   #region "Requests"
      [ApiResponse(200, "Records retrieved OK")]
      [ApiResponse(401, "Not authenticated")]
      [ApiResponse(404, "Handler for Request not found")]
      public static class InsertToDoRequest
      {
         public static string InvoiceID { get; set; }
         public static string MsgSubject { get; set; }
         public static string MsgBody { get; set; }
         public static string AssignTo { get; set; }
      }          
   #endregion
      
   #region "BusinessLogicPlugin"
   public class BusinessLogicPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogicPlugin
   {

       public override object InitializeLifetimeService()
       {
           // returning null here will prevent the lease manager
           // from deleting the Object.
           return null;
       }

       public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
       {
         if (JiwaBusinessLogic is JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote)
         {         
            JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote quote = (JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote)JiwaBusinessLogic;
            quote.SaveEnd += Quote_SaveEnd;
         }
       }
      
      private void Quote_SaveEnd(object sender, System.EventArgs e)
      {
         JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote quote = (JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote)sender;
         
         if (quote.InsertFlag)
         {
            // insert flag indicates it was created.
            JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo toDo = quote.Manager.BusinessLogicFactory.CreateBusinessLogic&lt;JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo&gt;(null);
               toDo.CreateNew();
               toDo.AssignedTo.ReadRecordByUsername("Admin");
               toDo.Subject = "New Quote Created";

               toDo.Body = String.Format("Quote {0} was created.", quote.QuoteNo);

               toDo.ReminderPredefinedSetting = JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo.ReminderPredefinedSettingType.WhenDue;
               toDo.ReminderSpecificDateTime = DateTime.Now;
               toDo.ReminderEnabled = true;
               toDo.Save();
         }
      }
   }
   #endregion
   #region "Services"   
      public class CustomServices : Service
      {
         [Authenticate]
         public static void InsertToDoRequest()
           {
               Manager manager = new Manager();
            
                JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo toDo = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo>(null);
                toDo.CreateNew();
                toDo.AssignedTo.ReadRecordByUsername(request.AssignTo);
                toDo.Subject = request.MsgSubject;
                toDo.Body = request.MsgBody;
                toDo.ReminderPredefinedSetting = JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo.ReminderPredefinedSettingType.WhenDue;
                toDo.ReminderSpecificDateTime = DateTime.Now;
                toDo.ReminderEnabled = true;
                toDo.Save();
              
           }
      }
 
   #endregion
}
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Plugin error message jiwa.

Postby Mike.Sheen » Tue Aug 29, 2023 5:37 pm

JuiceyBrucey wrote:Version SR 16, 7.2.1
When trying to save the plugin, I get this error message.
Error message:
the type of namespace name 'jiwaSales' does not exist in the namespace 'JiwaFinancialsJiwa' are you missing an assembly referance?


The error message describes the problem - the plugin doesn't have a reference to the JiwaSales.dll

You can either add it by explicitly adding the JiwaSales.dll to the Assembly References tab, or it will be added for you if you add either the sales order entry form to the Forms tab, or the sales order business logic to the Business Logic tab.

If your plugin wants to modify business logic behaviour then you probably want to add the sales order business logic to the Business Logic tab.

If your plugin wants to modify the form behaviour, then you probably want to add the sales order entry form to the Forms tab.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Mon Sep 04, 2023 1:07 pm

Thank you for reply.
That has cleared up that error message. As I am new to C#, some of this takes a bit of back ground learning.

So the code now looks like this:
Code: Select all
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using JiwaFinancials.Jiwa;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing;
using ServiceStack;
using ServiceStack.DataAnnotations;
using ServiceStack.Model;
using JiwaFinancials.Jiwa.JiwaServiceModel.Tables;
using ServiceStack.Auth;
using System.Linq;
using ServiceStack.OrmLite; // Db
using System.Configuration;

namespace JiwaFinancials.Jiwa.JiwaServiceModel
{
   public class RESTAPIPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaRESTAPIPlugin
   {
      public void Configure(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin, ServiceStack.ServiceStackHost  AppHost, Funq.Container Container, JiwaApplication.Manager JiwaApplicationManager)
      {         
         //System.Diagnostics.Debugger.Launch();
         //System.Diagnostics.Debugger.Break();
         AppHost.RegisterService<CustomServices>();
         //using InvoiceID from QO_Main table as id in ToDo (TD_Main) table
         AppHost.Routes.Add(typeof(InsertToDoRequest), "/Custom/InsertToDoRequest/{InvoiceID}/{MsgSubject}/{MsgBody}/{AssignTo}/", "GET", "Inserts a ToDo note associated with a quote to create an alert.", "");
      }
   }
   #region "Requests"
      [ApiResponse(200, "Records retrieved OK")]
      [ApiResponse(401, "Not authenticated")]
      [ApiResponse(404, "Handler for Request not found")]
      public static class InsertToDoRequest
      {
         public static string InvoiceID { get; set; }
         public static string MsgSubject { get; set; }
         public static string MsgBody { get; set; }
         public static string AssignTo { get; set; }
      }          
   #endregion
      
   #region "BusinessLogicPlugin"
   public class BusinessLogicPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogicPlugin
   {

       public override object InitializeLifetimeService()
       {
           // returning null here will prevent the lease manager
           // from deleting the Object.
           return null;
       }

       public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
       {
         if (JiwaBusinessLogic is JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote)
         {         
            JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote quote = (JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote)JiwaBusinessLogic;
            quote.SaveEnd += Quote_SaveEnd;
         }
       }
      
      private void Quote_SaveEnd(object sender, System.EventArgs e)
      {
         JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote quote = (JiwaFinancials.Jiwa.JiwaSales.SalesQuote.SalesQuote)sender;
         
         if (quote.InsertFlag)
         {
            // insert flag indicates it was created.
            JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo toDo = quote.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo>(null);
               toDo.CreateNew();
               toDo.AssignedTo.ReadRecordByUsername("Admin");
               toDo.Subject = "New Quote Created";

               toDo.Body = String.Format("Quote {0} was created.", quote.QuoteNo);

               toDo.ReminderPredefinedSetting = JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo.ReminderPredefinedSettingType.WhenDue;
               toDo.ReminderSpecificDateTime = DateTime.Now;
               toDo.ReminderEnabled = true;
               toDo.Save();
         }
      }
   }
   #endregion
   #region "Services"   
      public class CustomServices : Service
      {
         [Authenticate]
         public static void InsertToDoRequest()
           {
               JiwaFinancials.Jiwa.JiwaApplication.Manager manager = new JiwaFinancials.Jiwa.JiwaApplication.Manager();
            
                JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo toDo = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo>(null);
                toDo.CreateNew();
                toDo.AssignedTo.ReadRecordByUsername(request.AssignTo);
                toDo.Subject = request.MsgSubject;
                toDo.Body = request.MsgBody;
                toDo.ReminderPredefinedSetting = JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo.ReminderPredefinedSettingType.WhenDue;
                toDo.ReminderSpecificDateTime = DateTime.Now;
                toDo.ReminderEnabled = true;
                toDo.Save();
              
           }
      }
 
   #endregion
}

And now I am getting this error:
"the name 'request' does not exist in the current context"
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Plugin error message jiwa.

Postby Mike.Sheen » Tue Sep 05, 2023 10:58 am

JuiceyBrucey wrote:And now I am getting this error:
"the name 'request' does not exist in the current context"


Sounds like you're missing a namespace. Either fully qualify the reference to the request type or add a using statement.

If you export the plugin to XML (utilities tab of Plugin Maintenance form) and attach the plugin here, one of us can import it and get the same error and help you fix it. Providing code snippets is difficult to debug / diagnose.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Tue Sep 05, 2023 5:54 pm

That would be greatly appreciated.
Thank you very much.
Will do.
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Wed Sep 06, 2023 9:25 am

Here is the exported plugin.
Thank you very much for helping with this.
Cheers
Attachments
Plugin REST API insert ToDo record.xml
(27.18 KiB) Downloaded 114 times
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Wed Sep 06, 2023 9:28 am

P.S. I realise this is set to disabled.
<IsEnabled>false</IsEnabled>
I could not enable it due to the errors.
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Re: Plugin error message jiwa.

Postby Mike.Sheen » Thu Sep 07, 2023 10:59 am

Attached is a revised version of your plugin, such that it compiles.

Your issue was that you were referring to a request and not defining it.

So,

Code: Select all
public static void InsertToDoRequest()


Changed to:

Code: Select all
public void Post(InsertToDoRequest request)


I also needed to change your static class and property types to be not static.

And I wrapped your creating of the JiwaApplication.Manager in a using statement to make sure it is disposed properly - not doing that will result in connection pool exhaustion.

If you look in the REST API plugin, there are heaps of good examples of how to perform POST, PATCH, GET and DELETE operations - you can use those as a boilerplate guide.
Attachments
Plugin REST API insert ToDo record - v1.0.0.1.xml
(28.19 KiB) Downloaded 116 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Plugin error message jiwa.

Postby Mike.Sheen » Thu Sep 07, 2023 11:55 am

After looking further, there are some other fixes needed before this has a hope of working.

I didn't notice at first, but you were creating a new JiwaApplication.Manager instance - you shouldn't do that and that will not work - you need to retrieve it from the request and to do that you need the extension method GetManager() which is defined in the REST API plugin, so you need to add a Plugin reference to that.

Revised plugin attached.
Attachments
Plugin REST API insert ToDo record - v1.0.0.2.xml
(28.77 KiB) Downloaded 113 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Plugin error message jiwa.

Postby JuiceyBrucey » Fri Sep 08, 2023 2:35 pm

thank you very much for the reply.
I am still getting an error unfortunately.
Please see attached image.
Thank you.
Cheers
Attachments
error-2.png
error-2.png (110.78 KiB) Viewed 6546 times
JuiceyBrucey
Frequent Contributor
Frequent Contributor
 
Posts: 132
Joined: Tue Aug 18, 2020 7:19 pm
Topics Solved: 1

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 29 guests