Skip to main content

Auftrag via Script aus dem Client Proj. im MASTERProj. starten

Comments

1 comment

  • Zendesk API User
    Author: th_biedermann - 7/28/2015 14:30

    Hallo Thorsten,

    Wir mussten den Script ein bisschen umschreiben. Aber jetzt funktioniert es einwand frei.

    //! Beanshell

    import java.util.*;

    import de.espirit.firstspirit.access.*;

    ProjectId="";

    AuftragsId="";

    Long projectIdLongValue = null;

    Long auftragsIdLongValue = null;

    tasklist = context.getTasks();

    t = context.getTask();

    s = t.getScheduleEntry();

    p = s.getProject();

    log = "Start Remote ScheduleTask \"" + p.getName() + "\": ";

    context.logInfo(log + "script started");

    params = t.getParameters();

    for(pa: params) {

        switch(pa.getKey()) {

        case "ProjectId":

            ProjectId = pa.getValue();

            break;

        case "AuftragsId":

            AuftragsId = pa.getValue();

            break;

        }

    }

    if(ProjectId==null || ProjectId.trim().equals("")) {

        context.logError(log + "failed. Parameter \"ProjectId\" missing.");

        return;

    }else{

        try{

            projectIdLongValue = Long.parseLong(ProjectId);

        }catch(Exception e){

            context.logError("Exception: ProjectId ["+ProjectId+"] is not parseable! ["+e.getLocalizedMessage()+"]");

            return;

        }

    }

    if(AuftragsId == null || AuftragsId.trim().equals("")) {

        context.logError(log + "failed. Parameter \"AuftragsId\" missing.");

        return;

    }else{

        try{

            auftragsIdLongValue = Long.parseLong(AuftragsId);

        }catch(Exception e){

            context.logError("Exception: AuftragsId ["+AuftragsId+"] is not parseable! ["+e.getLocalizedMessage()+"]");

            return;

        }

    }

    UserService us = connection.getProjectById(projectIdLongValue).getUserService();

    AdminService ad = us.getConnection().getService(AdminService.class);

    context.logInfo(log + ": ProjectId=("+projectIdLongValue+"), AuftragsId=("+auftragsIdLongValue+")");

    List<ScheduleEntry> entriesx = ad.getScheduleStorage().getScheduleEntries(userService.getConnection().getProjectById(projectIdLongValue));

    if(entriesx!=null){

    context.logInfo("size = "+entriesx.size());

    for(ScheduleEntry se : entriesx){

    context.logInfo("entry: "+se.getName());

    }

    }else{

    context.logInfo("is null");

    }

    ScheduleEntry scheduleEntry = ad.getScheduleStorage().getScheduleEntry(userService.getConnection().getProjectById(projectIdLongValue), AuftragsId);

    scheduleEntry.execute().awaitTermination();

    context.logInfo(log + " script completed");

    0

Please sign in to leave a comment.