Hello,
Im working on a widget that has the following structure:
request (as solicitud in the code)
activity (as actividad in the code)
activityDetail (as detalleActividad in the code).
1 request can have 1..* activities.
1 activity can have 1..* detailActivity.
1 detailActivity can have 2 attachment associated (pictures) (its done through arcgisServer)
Im developing a code in a button that it has to validate the existence of 2 pictures on each detailActivity and say to the user:
if alldetailsActivityHasAttachment
change the requestState to Complete
else
Msg(you need to make sure that all the detailsActivity has their pictures before to change the state to Complete.
So, my function that it is trigged by a button is the following:
publicfunction verificarRealizacion():void{
var validado:String = "NO";
//VALIDAR EXISTENCIA DE ACTIVIDADES RELACIONADAS
var queryTask:QueryTask = new QueryTask(widgets.MantenimientoPodas.URLS.URL_ACTIVIDADES);
var query:Query = new Query();
query.where = "COD_SAP= " +int(DataSolicitudes.selectedItem['CODIGO_SAP']);
query.outFields = ['*'];
query.returnGeometry = true;
queryTask.execute(query, new AsyncResponder(onResultQuery, onFaultQuery));
//si hay conexion con el servicio
function onResultQuery(featureSet:FeatureSet, token:Object = null):void
{
//si no hay actividades asociadas a esa solicitud
if (featureSet.features.length<=0){
Alert.show("NO HAY Actividades encontradas, asegúrese de haberlas creado junto con su detalle especificado.");
//Si hay actividades asociadas. Verificar existencia de detalle
}else{
//Validar existencia de detalle
for(var k:int=0;k<featureSet.features.length;k++){
//VALIDAR EXISTENCIA DE DETALLE DE ACTIVIDAD RELACIONADOS
var queryTask:QueryTask = new QueryTask(widgets.MantenimientoPodas.URLS.URL_DETALLE_ACTIVIDADES);
var query:Query = new Query();
query.where = "ID_ACTIVIDAD= " +int(featureSet.features.attributes["ID_ACTIVIDAD"]);
query.outFields = ['*'];
query.returnGeometry = true;
queryTask.execute(query, new AsyncResponder(onResult, onFault));
function onResult(featureSet2:FeatureSet, token:Object = null):void
{
//Hay detalle de actividades
if(featureSet2.features.length>0){
//VALIDAR EXISTENCIA DE DOS FOTOS EN EL SERVICIO POR CADA DETALLE DE ACTIVIDAD
for(var m:int=0;m<featureSet2.features.length;m++)
{
//Alert.show(featureSet2.features.attributes["OBJECTID"]);
var myDetalle:FeatureLayer = new FeatureLayer(widgets.MantenimientoPodas.URLS.URL_DETALLE_ACTIVIDADES);
var objActividad:int= featureSet2.features.attributes["OBJECTID"];
myDetalle.queryAttachmentInfos(objActividad,new AsyncResponder(onResult,onFault));
function onResult(event:Array, token:Object=null):void
{
//tiene attachment
if (event.length==2)
{
var ModificarEstadoSolicitud:* = new Object;
ModificarEstadoSolicitud["OBJECTID"]= DataSolicitudes.selectedItem['OBJECTID'];
ModificarEstadoSolicitud["ID_ACTIVIDAD"]= int(DataSolicitudes.selectedItem['CODIGO_SAP']);
ModificarEstadoSolicitud["ESTADO_SOLICITUD"]= DDLEstadoPoda.selectedItem.descripcion;
var graficoEditadoActual:Graphic = new Graphic;
graficoEditadoActual = new Graphic(null,null,ModificarEstadoSolicitud);
var mySolicitud:FeatureLayer = new FeatureLayer(widgets.MantenimientoPodas.URLS.URL_SOLICITUD);
mySolicitud.applyEdits(null,[graficoEditadoActual],null, false,new AsyncResponder(onResult, onFault));
function onResult():void
{
Alert.show("Estado de Solicitud de Poda Modificado");
querySolicitudes();
}
function onFault(info:Object, token:Object = null):void
{
Alert.show("Error al modificar el estado de solicitud "+info.toString());
}
}
//no tiene attachment
else
{
Alert.show("Falta adjuntar alguna fotografia. Revise por favor.");
//Alert.show(event[0].url + " "+ event[1].url+ ""+ validado);
}
}
function onFault(event:Object,token:Object=null):void{
Alert.show("No se pudo conectar al servicio de fotos adjuntas");
}
}//for
}//if
else {
Alert.show("No hay detalle de actividades asociado, asegúrese de haber ingresado al menos uno por cada actividad");
}
}
function onFault(info:Object, token:Object = null):void
{
Alert.show("Error obteniendo el estado de la solicitud: "+ info.toString());
}
}
}
}
//no hay conexion
function onFaultQuery(info:Object, token:Object = null):void
{
Alert.show("Error al validar las actividades","Carga de Actividades");
}
}
My issue is im just getting if the detailActivity has their attachment one by one.
Is there a way to ask for all of them or another way to validate (the logic mainly).
Thanks in advice