Quantcast
Viewing all articles
Browse latest Browse all 5661

Instance manager like output code modification

Dear Experts,

 

I have a two jsp codes where it produces a tabular webpage output similar to Instance manager.

 

1. I would like to add Error Message to the code, I guess getErrorMessage() gives but not sure how to add it in the code.

2. When the Folder Path is null the adjacent column data is moved left.

3. Is it possible to run this code as a program object and schedule using CMC?

 

Code-1

------------------------

<%@ page import="com.crystaldecisions.sdk.plugin.desktop.program.*,

com.crystaldecisions.sdk.framework.*,

com.crystaldecisions.sdk.occa.infostore.*,

com.crystaldecisions.sdk.exception.*,

java.io.FileWriter, java.io.IOException,

com.crystaldecisions.sdk.properties.IProperties,

com.crystaldecisions.sdk.properties.IProperty,

com.crystaldecisions.sdk.plugin.desktop.folder.*,

java.util.*,java.text.*,

java.io.*"

%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFCell"%>

<%@ page import="org.apache.poi.hssf.usermodel.HSSFRow"%>

 

<html>

<head></head>

<body>

<table border="2" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">

<tr>

  <th width="10%"> Id</th>

  <th width="20%"> Title</th>

  <th width="10%"> Type</th>

  <th width="10%"> Status</th>

  <th width="30%">Folder</th>

  <th width="20%">Owner</th>

  <th width="20%">NextRunTime </th>

  <th width="20%">CreationTime </th>

  <th width="20%">StartTime </th>

  <th width="20%">EndTime </th>

  <th width="20%">Recurrence </th>

  <th width="20%">Duration</th>

  <th width="20%">Server</th>

  <th width="20%">Destination</th>

  <th width="20%">Frequency</th>

 

</tr>

<%

//<th width="30%">Folder Path </th>

 

 

  

        String user = request.getParameter("username");

  String password = request.getParameter("password");        

  String cmsName = request.getParameter("cmsname");        

  String cmsAuthType = request.getParameter("authType");

  String paramStartTime = request.getParameter("start");  

  String paramEndTime = request.getParameter("end");  

  String reportInstanceStartTime=null;

  String reportInstanceEndTime=null;

  String reportCreationTime=null;

  String statusCheck=null;

  String typeCheck=null;

  String reportOwner=null;

  String reportNextRuntime=null;

  String finalFolderPath=null;

  String recurringProp=null;

  long diffSeconds=0;

  String serverProp=null;

  java.util.Date startTime=null;

        java.util.Date endTime=null;

  java.util.Date creationTime=null;

  java.util.Date nextRunTime=null;

       

        String DATE_FORMAT="dd/MM/yyyy HH:mm:ss";

 

  IEnterpriseSession es=null;

  

  int index = 1;

   

      

  try

  {

  es = CrystalEnterprise.getSessionMgr().logon( user, password, cmsName, cmsAuthType);                

  IInfoStore iStore = (IInfoStore) es.getService("", "InfoStore");

  //IInfoObjects infoobjects = iStore .query("select si_name,si_nameduser,si_userfullname from ci_systemobjects where si_kind='user'"); 

  //IInfoObjects infoobjects = iStore .query("select top 10000 * from ci_infoobjects where si_instance=1 and si_starttime>='2014.12.01.00.00.00' and si_starttime<='2014.12.31.00.00.00' order by si_starttime desc");

  StringBuilder sqlQuery = new StringBuilder();

  sqlQuery.append("select * from ci_infoobjects where si_instance=1 and si_starttime>='")

  .append(paramStartTime)

  .append("' and si_starttime<='")

  .append(paramEndTime)

  .append("' order by si_starttime");

  IInfoObjects infoobjects = iStore.query(sqlQuery.toString());

 

  //IInfoObjects infoobjects = iStore .query("select * from ci_infoobjects where si_instance=1 and si_starttime>='2015.04.18.00.00.00' and si_starttime<='2015.04.19.20.00.00' order by si_starttime");

  //IInfoObjects infoobjects = iStore .query("select top 20000 * from ci_infoobjects where si_instance=1 and si_parentid='5474529' ");

  SimpleDateFormat sdf= new SimpleDateFormat(DATE_FORMAT);

  for(int i=0;i<infoobjects.size();i++)

  {

  int count=i+1;

  IInfoObject infoobject=(IInfoObject) infoobjects.get(i);

  IProperties reportProperties=(IProperties)infoobject.properties();

  ISchedulingInfo schedInfo=infoobject.getSchedulingInfo();

  IProperties schedProperties=schedInfo.properties();

  int reportID=infoobject.getID();

  String reportName=infoobject.getTitle();

  String reportKind=infoobject.getKind();

  out.println("<tr><td>"+reportID+"</td>");

  out.println("<td>"+reportName+"</td>");

  out.println("<td>"+reportKind+"</td>");

 

  int status=schedInfo.getStatus();

 

  switch(status)

  {

  case ISchedulingInfo.ScheduleStatus.COMPLETE: //Job is completed

  statusCheck="COMPLETE";

  out.println("<td>"+statusCheck+"</td>");

 

  break;

 

  case ISchedulingInfo.ScheduleStatus.FAILURE: //Job has failed.

  statusCheck="FAILURE";

  out.println("<td>"+statusCheck+"</td>");

 

  break;

    

  case ISchedulingInfo.ScheduleStatus.PAUSED: //Job is paused.

  statusCheck="PAUSED";

  out.println("<td>"+statusCheck+"</td>");

  break;

    

  case ISchedulingInfo.ScheduleStatus.PENDING: //Job is pending.

  statusCheck="PENDING";

  out.println("<td>"+statusCheck+"</td>");

  break;

    

  case ISchedulingInfo.ScheduleStatus.RUNNING: //Job is running.

  statusCheck="RUNNING";

  out.println("<td>"+statusCheck+"</td>");

  break;

 

  }

 

 

  int id=infoobject.getParentID();

 

 

 

  IInfoObjects infoobjects1 = iStore .query("SELECT * from CI_INFOOBJECTS WHERE  si_id="+id);

 

 

  IInfoObject infoobject1=(IInfoObject)infoobjects1.get(0);

 

 

 

  int parentid=infoobject1.getParentID();

 

 

  IInfoObjects infoobjects2 = iStore .query("SELECT * from CI_INFOOBJECTS WHERE  si_id="+parentid);

 

 

  IInfoObject infoobject2=(IInfoObject)infoobjects2.get(0);

  if(infoobject2.getKind().equals("Folder"))

  {

    finalFolderPath="/";

   IFolder iifolder=(IFolder)infoobject2;

   if(iifolder.getPath()!= null)

   {

    String path[]=iifolder.getPath();

    for(int fi=0;fi<path.length;fi++)

    {

     finalFolderPath =  "/"+path[fi]+ finalFolderPath;

  

    }

     finalFolderPath = finalFolderPath+iifolder.getTitle();

   }

   else

   {

    finalFolderPath=finalFolderPath+iifolder.getTitle();

   }

 

   out.println("<td>"+finalFolderPath+"</td>");

 

  }

 

  IProperty reportProperty=reportProperties.getProperty("SI_OWNER");

  reportOwner=reportProperty.getValue().toString();

  out.println("<td>"+reportOwner+"</td>");

       

  if(reportProperties.getProperty("SI_NEXTRUNTIME")  != null)

  {

  nextRunTime=reportProperties.getDate("SI_NEXTRUNTIME");

  reportNextRuntime=sdf.format(nextRunTime);

  out.println("<td>"+reportNextRuntime+"</td>");

  }

  else

  {

  reportNextRuntime="Property Doesnot exists";

  out.println("<td>"+reportNextRuntime+"</td>");

  }

 

 

 

  if(reportProperties.getProperty("SI_CREATION_TIME") != null)

  {

  creationTime = reportProperties.getDate("SI_CREATION_TIME");

  reportCreationTime=sdf.format(creationTime);

  out.println("<td>"+reportCreationTime+"</td>");

  }

  else

  {

  reportCreationTime="Property Doesnot exists";

  out.println("<td>"+reportCreationTime+"</td>");

  }

 

  if(reportProperties.getProperty("SI_STARTTIME") != null)

                {

  startTime=reportProperties.getDate("SI_STARTTIME");

  reportInstanceStartTime=sdf.format(startTime);

  out.println("<td>"+reportInstanceStartTime+"</td>");

  startTime=sdf.parse(reportInstanceStartTime);

  }

  else

  {

  reportInstanceStartTime="Property Doesnot exists";

  out.println("<td>"+reportInstanceStartTime+"</td>");

  }

  if(reportProperties.getProperty("SI_ENDTIME") != null)

                {

  endTime=reportProperties.getDate("SI_ENDTIME");

  reportInstanceEndTime=sdf.format(endTime);

  out.println("<td>"+reportInstanceEndTime+"</td>");

  endTime=sdf.parse(reportInstanceEndTime);

  }

  else

  {

  reportInstanceEndTime="Property Doesnot exists";

  out.println("<td>"+reportInstanceEndTime+"</td>");

  }

 

  IProperty recurringProperty=reportProperties.getProperty("SI_RECURRING");

  recurringProp=recurringProperty.getValue().toString();

  out.println("<td>"+recurringProp+"</td>");

  if(recurringProp.equals("false"))

  {

  long diff=endTime.getTime() - startTime.getTime();

  diffSeconds=diff/1000;

  out.println("<td>"+diffSeconds+"</td>");

  }

  else

  {

  out.println("<td>Not Applicable</td>");

  }

  IProperty serverProperty=schedProperties.getProperty("SI_MACHINE_USED");

  if(serverProperty!=null)

  {

  serverProp=serverProperty.getValue().toString();

  //out.println("<td>"+serverProp+"</td></tr>");

  out.println("<td>"+serverProp+"</td>");

  }

  else

  {

  serverProp="Server Not assigned";

  out.println("<td>"+serverProp+"</td>");

  }

  IProperty destProperty=schedProperties.getProperty("SI_DESTINATIONS");

  out.println("<td>"+destProperty+"</td>");

 

 

  int type=schedInfo.getType();

  //out.println(type);

  if (type!=0){

  switch(type)   

  {  

  case CeScheduleType.ONCE:    

  typeCheck="ONCE";  

  out.println("<td>"+typeCheck+"</td>");     

  break;

  

  case CeScheduleType.HOURLY:

  typeCheck="HOURLY"; 

  out.println("<td>"+typeCheck+"</td>"); 

  break;         

  case CeScheduleType.DAILY:   

  typeCheck="DAILY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;         

  case CeScheduleType.WEEKLY:

  typeCheck="WEEKLY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;       

  case CeScheduleType.MONTHLY:   

  typeCheck="MONTHLY";    

  out.println("<td>"+typeCheck+"</td>"); 

  break;        

  case CeScheduleType.NTH_DAY: 

  typeCheck="NTH_DAY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;           

  case CeScheduleType.FIRST_MONDAY:  

  typeCheck="FIRST_MONDAY";  

  out.println("<td>"+typeCheck+"</td>"); 

  break;         

  case CeScheduleType.LAST_DAY:   

  typeCheck="LAST_DAY";    

  out.println("<td>"+typeCheck+"</td>");   

  break;        

  case CeScheduleType.CALENDAR: 

  typeCheck="CALENDAR"; 

  out.println("<td>"+typeCheck+"</td>");    

  break;           

  case CeScheduleType.CALENDAR_TEMPLATE:

  typeCheck="CALENDAR_TEMPLATE";  

  out.println("<td>"+typeCheck+"</td>");    

  break;

  }

 

  }

  else {

  out.println("<td>Now</td>");

  }

                    index++;

 

  }

  }

 

 

      catch(SDKException e)

  {

  out.println(e.getMessage());

  }

  finally

  {

  es.logoff();

  }

%>

 

Code 2

-----------------------

<%

%>

 

 

<HTML>

  <HEAD>

    <TITLE></TITLE>

  </HEAD>

  <BODY>

  <table>

    <form action="InstanceDetails.jsp" method="post">

        <tr><td>CMS Name: </td><td><input name="cmsname" ></td></tr>

        <tr><td>User Name: </td><td><input name="username" ></td></tr>

        <tr><td>Password: </td><td><input type="password" name="password"></td></tr>

        <tr><td>Start</td><td><input name="start"></td></tr>

        <tr><td>End: </td><td><input name="end"></td></tr>

        <tr>

        <tr><td>Authentication Type:</td><td>

  <select name="authType" size=1 width="250">

                <option value='secEnterprise' selected>Enterprise</option>

                <option value='secLDAP'>LDAP</option>

            </select>

            </td></tr>

            <tr></tr>

        <tr><td>

      <P> </P><td></td></tr>

       <tr><td><INPUT type=submit value=submit></form></td></tr>

     

</table>

</BODY></HTML>

 

Please advise


Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>