Informazioni commerciali +39 0575 05077
  Assistenza telefonica +39 0575 0508
 
Computing > 6 - Manipolazione Schedulazioni > Sospendere una operazione

6.5 Sospendere una operazione

Tramite il metodo SetUpdateServerScheduledOperation è possibile modificare un'operazione schedulata riccorente per sospendere l'operazione.

Parametri utilizzati
operationId
Type: int
Oggetto di int che indica l'identificativo dell'operazione da modificare


Per sospendere l'operazione è necessario ottenere i dati dell'operazione da sospendere. Ciò è possibile tramite il metodo GetScheduledOperations che fornisce tutte le operazioni attive.
/// IWsEndUser.SetUpdateServerScheduledOperation Method (c# .NET)
public static string SetSuspendServerScheduledOperation(WsEndUserClient client,
        int operationId)
{
    //specify the account login details 
    client.ClientCredentials.UserName.UserName = "ARU-0000";
    client.ClientCredentials.UserName.Password = "0123456789";

    StringBuilder stringBuilder = new StringBuilder();

    try
    {
        // create the object GetScheduledOperationRequest  for the request 
        // with data to process
        GetScheduledOperationRequest request = new GetScheduledOperationRequest();

        // call method GetScheduledOperations, 
        // obtaining a WsResultOfArrayOfScheduledOperation item               
        WsResultOfArrayOfScheduledOperation result =
                client.GetScheduledOperations(request);

        //if the call is Success print history values
        if (result.Success)
        {
            // get Value returned from server
            ScheduledOperation[] scheduledOperations = result.Value;

            // set start value to null
            ScheduledOperation operationToSuspend = null;

            // search inside scheduled operations
            foreach (ScheduledOperation operation in scheduledOperations)
            {
                if (operation.ScheduledOperationID == operationId)
                {
                    // fount it
                    operationToSuspend = operation;
                    break;
                }
            }

            // if the operationTosupend is not null it was found 
            if (operationToSuspend != null)
            {
                // create the object SetUpdateScheduledOperationRequest  for the request 
                // with data to process
                SetUpdateScheduledOperationRequest scheduledOperationRequest = 
                    new SetUpdateScheduledOperationRequest();

                scheduledOperationRequest.ScheduledOperationId = operationId;

                // copy all information about schedule plan from current settings 
                SchedulePlan plan = new SchedulePlan();
                plan.ScheduleStartDateTime = 
                    operationToSuspend.ScheduledPlan.ScheduleStartDateTime;
                plan.ScheduleEndDateTime = 
                    operationToSuspend.ScheduledPlan.ScheduleEndDateTime;
                plan.ScheduleOperationLabel = 
                    operationToSuspend.ScheduledPlan.ScheduleOperationLabel;
                plan.ScheduleFrequencyType = 
                    operationToSuspend.ScheduledPlan.ScheduleFrequencyType;
                plan.ScheduledMontlyRecurrence = 
                    operationToSuspend.ScheduledPlan.ScheduledMontlyRecurrence;
                plan.ScheduleFrequency = 
                    operationToSuspend.ScheduledPlan.ScheduleFrequency;
                plan.ScheduleDaysOfMonth = 
                    operationToSuspend.ScheduledPlan.ScheduleDaysOfMonth;
                plan.ScheduleWeekDays = 
                    operationToSuspend.ScheduledPlan.ScheduleWeekDays;

                // set the ScheduledPlanStatus  to "disabled" 
                plan.ScheduledPlanStatus = ScheduledPlanStatus.Disabled;

                scheduledOperationRequest.SchedulePlan = plan;

                // call method SetUpdateServerScheduledOperation 
                // obtaining a WsResult item
                WsResult result2 =
                    client.SetUpdateServerScheduledOperation(scheduledOperationRequest);

                //if the call is Success print history values
                if (result2.Success)
                {
                    // get Value returned from server
                    stringBuilder.Append(" Operation successfully. Result Code : ");
                    stringBuilder.Append(result2.ResultCode);
                }
                else
                {
                    throw new ApplicationException(result.ResultMessage);
                }
            }
            else
            {
                // scheduled operation not found
                throw new ApplicationException("Operation not found.");
            }
        }
        else
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }
    catch (Exception ex)
    {
        // re-run the error
        throw new ApplicationException(ex.Message);
    }

    return stringBuilder.ToString();
}
// IWsEndUser.SetUpdateServerScheduledOperation Method (JAVA)
public static String SetSuspendServerScheduledOperation(IWsEndUser client,
        int operationId)
{
    //specify the account login details 
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");

    StringBuilder stringBuilder = new StringBuilder();

    try
    {
        // create the object GetScheduledOperationRequest  for the request 
        // with data to process
        GetScheduledOperationRequest request = new GetScheduledOperationRequest();

        // call method GetScheduledOperations, 
        // obtaining a WsResultOfArrayOfScheduledOperation item               
        WsResultOfArrayOfScheduledOperation result =
                client.getScheduledOperations(request);

        //if the call is Success print history values
        if (result.isSuccess())
        {
            // get Value returned from server
            ArrayOfScheduledOperation scheduledOperations = result.getValue();

            // set start value to null
            ScheduledOperation operationToSuspend = null;

            List<ScheduledOperation> listOfScheduledOperation = 
                    scheduledOperations.getScheduledOperation();
                
            // search inside scheduled operations
            for (Iterator<ScheduledOperation> it = 
                listOfScheduledOperation.iterator(); it.hasNext();)
            {
                ScheduledOperation operation = it.next();
                if (operation.getScheduledOperationID() == operationId)
                {
                    // fount it
                    operationToSuspend = operation;
                    break;
                }
            }

            // if the operationTosupend is not null it was found 
            if (operationToSuspend != null)
            {
                // create the object SetUpdateScheduledOperationRequest for the request 
                // with data to process
                SetUpdateScheduledOperationRequest scheduledOperationRequest = 
                    new SetUpdateScheduledOperationRequest();

                scheduledOperationRequest.setScheduledOperationId(operationId);

                // copy all information about schedule plan from current settings 
                SchedulePlan plan = new SchedulePlan();
                plan.setScheduleStartDateTime(
                    operationToSuspend.getScheduledPlan().getScheduleStartDateTime());
                plan.setScheduleEndDateTime(
                    operationToSuspend.getScheduledPlan().getScheduleEndDateTime());
                plan.setScheduleOperationLabel(
                    operationToSuspend.getScheduledPlan().getScheduleOperationLabel());
                plan.setScheduleFrequencyType( 
                    operationToSuspend.getScheduledPlan().getScheduleFrequencyType());
                plan.setScheduledMontlyRecurrence(
                    operationToSuspend.getScheduledPlan().getScheduledMontlyRecurrence());
                plan.setScheduleFrequency( 
                    operationToSuspend.getScheduledPlan().getScheduleFrequency());
                plan.setScheduleDaysOfMonth(
                    operationToSuspend.getScheduledPlan().getScheduleDaysOfMonth());
                plan.setScheduleWeekDays(
                    operationToSuspend.getScheduledPlan().getScheduleWeekDays());

                // set the ScheduledPlanStatus  to "disabled" 
                plan.setScheduledPlanStatus(ScheduledPlanStatus.DISABLED);

                scheduledOperationRequest.setSchedulePlan(plan);

                // call method SetUpdateServerScheduledOperation 
                // obtaining a WsResult item
                WsResult result2 =
                    client.setUpdateServerScheduledOperation(scheduledOperationRequest);

                //if the call is Success print history values
                if (result.isSuccess())
                {
                    // get Value returned from server
                    stringBuilder.append(" Operation successfully. Result Code : ");
                    stringBuilder.append(result2.ResultCode);
                }
                else
                {
                    throw new Exception(result.getResultMessage());
                }
            }
            else
            {
                // scheduled operation not found
                throw new Exception("Operation not found.");
            }
        }
        else
        {
            throw new Exception(result.getResultMessage());
        }
    }
    catch (Exception ex)
    {
        // re-run the error
        System.out.println(ex);
    }

    return stringBuilder.toString();
}
Versione
API: v2.8 URL:https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl
Vedi anche




Bookmark and Share