Mattersphere Developers Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
avatar
Admin
Admin
Posts : 122
Join date : 2018-12-17
https://mattersphere-devs.forumotion.com

Saving a Job List Empty Saving a Job List

Thu 20 Dec 2018 - 12:32
Original post by Mike Vaughan

Hi, I'm currently looking into using Job Lists in Taskflow and have some Code Snippets that are generating some errors.

I'm using the following code to pass to precedents names to my method which in turn adds them to a Job List.

Code:
CreateClientDocument(true, "CLI001", "CLI005");

public bool CreateClientDocument(bool useJobList, params string[] precedentList)
{
    for (int i = 0; i < precedentList.Length; i++)
    {
        try
        {
            FWBS.OMS.Precedent precedent =
                FWBS.OMS.Precedent.GetPrecedent(precedentList[i], null);
            
            FWBS.OMS.PrecedentJob newJob =
                new FWBS.OMS.PrecedentJob(
                    FWBS.OMS.Precedent.GetPrecedent(precedent.ID));
                    
            newJob.Associate = CurrentFile.DefaultAssociate;
            if (useJobList)
            {
                CurrentSession.CurrentPrecedentJobList.Add(newJob);
                CurrentSession.CurrentPrecedentJobList.Update();
            }
            else
            {
                FWBS.OMS.UI.Windows.Services.ProcessJob(null, newJob);
            }
        }
        catch (Exception ex)
        {
            MsgBox(ex.ToString(), "ERROR");
            return false;
        }
    }
    if (useJobList)
    {
        ProcessJobList();
    }
        
    return true;
}

The jobs are added to the list ok, but if I try and press Save on the Job List I get the following message: 

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

I clicked OK, pressed Cancel, and tried to run the Action again. This time an Exception was caught and the following message displayed in the message box:

[MISSING IMAGE]

Line 57 is the following line: 

Code:
CurrentSession.CurrentPrecedentJobList.Update(); 

Any idea what's going on here? cheers
avatar
Admin
Admin
Posts : 122
Join date : 2018-12-17
https://mattersphere-devs.forumotion.com

Saving a Job List Empty Re: Saving a Job List

Thu 20 Dec 2018 - 12:39
Original post by Mike Walker

Try not to run the Update method as is being ran twice and causing the currency violation. Also looking at the script the brackets maybe slightly wrong in that there is some code execution paths which might be causing a problem.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Original post by Mike Vaughan

I've removed the CurrentSession.CurrentPrecedentJobList.Update(); line from the method and it seems to work ok now.

Is the CurrentSession.CurrentPrecedentJobList.Update(); line is not needed at all in the method? 

The method itself was sent to us along with other example code from FWBS.

Thanks

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Original post by Mike Walker

This code snipet should be updated as the Add Job is doing the Update code, I believe this was a change as a number of problems were being caused by people not updating the JobList so we did this automatically. 

I would always suggest being economic in running update on Methods as these can cascade a number of things and or maybe done automatically depending on the helper method you are running, all you then maybe doing is getting the server to do the job again for no reason.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Original post by Peter Barnett

Hi Mike Try moving the CurrentSession.CurrentPrecedentJobList.Update(); into the second if(useJobList), that way it will only update after all of the precedents have been added. 

I would also consider a user prompt - “Documents have been added to the Job List, do you wish to process now?” at the same point.

It sounds like the job list is happily maintaining itself without the 'save'. Out of curiosity what happens if you don't process the job list straight away? And in that scenario what will happen if you add documents from more than one matter into the job list before processing. Peter

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Original post by Mike Vaughan

I created another dummy matter, added jobs to the job list and did not process them. 

I then added more jobs to the job list on another matter, processed them and the jobs from the previous matter were there as well as the current matter precedents. 

I clicked save and it worked fine, and after restarting Word the documents were still in the Job List. 

all seems to be working well now, thanks
Back to top
Permissions in this forum:
You cannot reply to topics in this forum