Erp.Contracts.BO.JobClosing


(Martin) #1

Hi, im trying to use the JobClosing method to close/open jobs in a BPM but no luck so far. No error returned and strOut string at the end is blank. Any idea? Here is code below. Thanks

var JobClosingTable = new Erp.Tablesets.JobClosingTableset();
Erp.Contracts.JobClosingSvcContract hC = null;
hC = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobClosingSvcContract>(Db);
string strOut = “”;
bool blnInput = false;

          if (hC != null) 
          { 
	JobClosingTable = new Erp.Tablesets.JobClosingTableset();

             hC.GetNewJobClosing(ref JobClosingTable);
            
            if (JobClosingTable != null) 
            { 
              
              var qDS = JobClosingTable.JobClosing;

              foreach(var row in qDS)
              {
                row.JobNum = strJobNum;
                row.QuantityContinue = 1;
                row.JobClosed = true;
                row.ClosedDate = DateTime.Now;
                
                hC.PreCloseJob(ref JobClosingTable, out blnInput);
                hC.CloseJob(ref JobClosingTable, out strOut);
                
              }
              
              
            }
            
           }

(Brad Fraser) #2

Have you tried outputting to the Application Log at different parts in the code to confirm what all runs?

Ice.Diagnostics.Log.WriteEntry(“Message Here”);


(Martin) #3

I’ve outputed messages (PublishInfoMessage) between each line to make sure that everything runs. I also have a try catch (which is not catching anything).

thanks,


(Brad Fraser) #4

What messages are you getting in your output?


(Martin) #5

Brad,

im outputing sequencial numbers that im hardcoding to spot where the code is at.

Also, as I mentioned, the strOut string is not outputing anything from hC.CloseJob(ref JobClosingTable, out strOut);

Thanks,


(David Arista) #6

I believe the OnChangeJobNum is missing, I have this example when closing with Backflush

Erp.Contracts.JobClosingSvcContract hJobC = null;
hJobC = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobClosingSvcContract>(Db);

if (hJobC != null)
{
//Closing with Backflush
hJobC.GetNewJobClosing(ref dsJobClosing);
hJobC.OnChangeJobNum(oper.Key1, ref dsJobClosing, out msg);

var jobC_Row = (from x in dsJobClosing.JobClosing
                where x.RowMod != ""
                select x).FirstOrDefault();
if (jobC_Row != null)
{
	jobC_Row.BackFlush = true;
	jobC_Row.JobComplete = true;
	jobC_Row.JobCompletionDate = DateTime.Today;
	hJobC.OnChangeJobCompletion(ref dsJobClosing);
	hJobC.PreCloseJob(ref dsJobClosing, out reqInput);
	hJobC.CloseJob(ref dsJobClosing, out msg);                                
}

}
hJobC = null;


(Louis Fequet) #7

Make sure your RowMod is properly set.


(Martin) #8

Thanks! It was what I was missing.