Cheeckout and checkin project while workflow is running

Unanswered Cheeckout and checkin project while workflow is running

  • Tuesday, February 21, 2012 5:22 PM
     
     

    HI,

     I need to update some custom fields programmatically in each workflow stage without having additional session (without checkout, update, publish and checkin the project) while running the workflow. I tried to get the session id but am getting PROJ_SESSION_UID as null value from ProjectDataSet. and could not able to update the project in the same context without checking-out and check-in with app pool account. Any Ideas??




    • Edited by ChicShare Tuesday, February 21, 2012 10:11 PM
    •  

All Replies

  • Wednesday, February 22, 2012 11:56 AM
     
     

    Hi,

    When your PROJ_SESSION_UID is null it means it's not checked out. You've to check out before updating ProjectDataSet. I'm not sure you can update the project while the workflow is running.

    Thanks


    Thanks, Kashif

  • Wednesday, February 22, 2012 2:19 PM
     
     

    HI Kashif,

    Thanks for your reply. User need to checkout the project to submit to the workflow. So I think it is in checked out to the specific user. I am able to check out and update the project but user's session is going away and they need to check out again every time they submit to the workflow. Yes, that is my basic question... can we update the project while workflow is running with the same context? Agian thanks for your reply.

  • Wednesday, February 22, 2012 2:48 PM
     
      Has Code

    Are you checking that from database directly of PSI? Confirm by running the following query from Draft and Published

    SELECT TOP 1000 [PROJ_UID]
          ,[PROJ_NAME]
          ,[PROJ_SESSION_UID]
    FROM [dbo].[MSP_PROJECTS]


    Thanks, Kashif

  • Wednesday, February 22, 2012 5:59 PM
     
     

    Hi Kashif,

    I am able to get the Session ID from database with that query. But now am getting ProjectCheckedOutToOtherUSer error since am just trying to update the project (with current context) by not cheking out again. I hope you understand my problem. Thanks.


    • Edited by ChicShare Wednesday, February 22, 2012 6:00 PM
    •  
  • Wednesday, February 22, 2012 6:09 PM
     
     

    I'm a little lost in the sequence.  I believe a project needs to be checked-in in order to call updateProjectProperty.

    Here's the sequence I use before updating custom fields (after the user hits Submit):

    1) Set new workflow stage;
    2) If project is checked out, check it in;
    3) call UpdateProjectProperty;
    4) Check project out in a new session;
    5) Publish project;
    6) Worlflow moves to the next stage and the project is still checked out to me (hence, step 3, but I'm not sure how new session is still associated with me).
    7) Update stage status.

    Ilya

  • Wednesday, February 22, 2012 6:45 PM
     
     

    You must have checked out the project from MSP or just go to Server Setting -> Force Check-in Enterprise Objects  and check in your project from there.

    Once that is done. Your code should follow this sequence.

    1. Check if Session Id  is there or not? If its there that means its already checked out and use the same ID for updating project or else create new one.  Check out Project is not.

    2. Update your project like custom fields, tasks whatever you like.

    3. Check in your project

    4. Publish

    You can follow  this url for code sample. Hope this help you out.

    Thanks


    Thanks, Kashif

  • Wednesday, February 22, 2012 6:53 PM
     
     
    Apologies: eliminate #4 from my post.  I do not check out the project at any time after checking it, yet it still appears to be checked out to me after all the operations are completed.
  • Friday, March 02, 2012 3:49 PM
     
     

    Hi Rock,

    I know it is long time. I am developing a kind of eventhandler for workflow stages.  I still got the issue with this approach. Here is my code,

    If I call QueueUpdate method without chekout throwing CICINotCheckedOur error.

    If I chekout the project and call update and checkin it is going fine but blocking the queue everytime.

    am I doing anything wrong?

    Guid sessionUid = CurrentSessionID; //Got from database
      psi.ProjectWebService.QueueCheckInProject(Guid.NewGuid(), projectGUID, true, sessionUid, "Checked in by system");
         try
       {
        sessionUid = Guid.NewGuid();
        //psi.ProjectWebService.CheckOutProject(projectGUID, sessionUid, "Check Out for Custom Field Update");
        psi.ProjectWebService.QueueUpdateProject(jobID, sessionUid, projDs, false);
        jobID = Guid.NewGuid();
        psi.ProjectWebService.QueuePublish(jobID, projectGuid, true, string.Empty);
        // psi.ProjectWebService.QueueCheckInProject(Guid.NewGuid(), projectGUID, true, sessionUid, "Checked in by system");
       }
       catch (Exception ex)
       {}
      


    • Edited by ChicShare Friday, March 02, 2012 4:06 PM
    •  
  • Friday, March 02, 2012 10:32 PM
     
     

    You are generating new Session ID, comment this

    sessionUid = Guid.NewGuid();

    then try and let us know.


    Thanks, Kashif