protected IRacoonResponse TryExecuteQueryMultiVariable(byte[] token, string sproc, IEnumerable <IConvertToMiddlewareParam> inputParams)
        {
            IRacoonResponse executeResponse = QueryExecution.ExecuteQueryAllTypes(token, sproc, inputParams, ParameterTypeEnum.AsSource | ParameterTypeEnum.Multivalue);

            if (!executeResponse.AuthorisationOK)
            {
                return(executeResponse);
            }
            MultiVariableResponse queryRes = executeResponse as MultiVariableResponse;

            if (queryRes == null)
            {
                executeResponse.Status = false;
                executeResponse.Error  = new InvalidCastException("Unexpected return type from query");
            }
            return(executeResponse);
        }
        protected ResposeType Respond <BOType, DCType, ResposeType>(byte[] token, string sproc, IEnumerable <IConvertToMiddlewareParam> inputParams)
            where BOType : IMappableBussinessObject
            where DCType : IPopulateFromBO, new()
            where ResposeType : SimpleRacoonResponse, IResponseWithBussinessObjectEnum, new()
        {
            IRacoonResponse queryRes = TryExecuteQueryMultiVariable(token, sproc, inputParams);
            ResposeType     response = new ResposeType();

            response.CloneToPopulate(queryRes);
            if (!queryRes.AuthorisationOK || !queryRes.Status)
            {
                return(response);
            }
            MultiVariableResponse multiVarRes       = queryRes as MultiVariableResponse;
            List <DCType>         dataContractItems = CreateBussinessObjectsFromResponse <BOType, DCType>(multiVarRes);

            if (dataContractItems.Count > 0)
            {
                response.SetOutputList(dataContractItems as IEnumerable <IPopulateFromBO>);
            }
            return(response);
        }
        public TaskOntologyResponse GetTaskOntologies(byte[] token)
        {
            IRacoonResponse      executeResponse = QueryExecution.ExecuteQueryAllTypes(token, SprocNames.GetTaskOntologies, Enumerable.Empty <IConvertToMiddlewareParam>(), ParameterTypeEnum.String & ParameterTypeEnum.Multivalue);
            TaskOntologyResponse response        = new TaskOntologyResponse(executeResponse);

            if (!response.AuthorisationOK)
            {
                return(response);
            }
            MultiVariableResponse queryRes = executeResponse as MultiVariableResponse;

            if (queryRes == null)
            {
                response.Status = false;
                response.Error  = new InvalidCastException("Unexpected return type from query");
                return(response);
            }
            else
            {
                List <TaskOntologyDataContract> returnableTaskOntologyList = new List <TaskOntologyDataContract>();
                foreach (MultiParameterResult param in queryRes.OutputParameters)
                {
                    if (param.Direction == ParameterDirection.Out)
                    {
                        MiddlewareParameter <List <MiddlewareParameter> > convertedParameter = (MiddlewareParameter <List <MiddlewareParameter> >)param.ToMiddlewareParam();
                        TaskOntology             availableTaskOntology  = MappedBussinessObjectFactory.CreateFromParamers <TaskOntology>(convertedParameter.ParamValue);
                        TaskOntologyDataContract returnableTaskOntology = new TaskOntologyDataContract(availableTaskOntology);
                        returnableTaskOntologyList.Add(returnableTaskOntology);
                    }
                }
                if (returnableTaskOntologyList.Count > 0)
                {
                    response.TaskOntologies = returnableTaskOntologyList;
                }
            }

            return(response);
        }
        public static IRacoonResponse ExecuteQueryAllTypes(byte[] token, string query, IEnumerable <IConvertToMiddlewareParam> inputParameterList,
                                                           ParameterTypeEnum returnTypeWanted, bool addLanuageParam = false)
        {
            Exception       error = null;
            IRacoonResponse res   = CreateResponse(returnTypeWanted);
            Session         currentSession;

            if (SessionStore.TryGetValidSession(token, out currentSession))
            {
                IEnumerable <ParameterBase> responseParameters = null;
                if (addLanuageParam)
                {
                    addLanuageParameter(inputParameterList, currentSession);
                }
                //ascertain if the passed string is a sp or a sparql query.
                //More complex differentiation could go here to allow things other
                //than stored procedures to be passed to other datastores for example
                if (query.Contains(" "))
                {
                    responseParameters = executeSPARQL(query, inputParameterList, currentSession, returnTypeWanted, out error);
                }
                else
                {
                    responseParameters = executeStoredProcedure(query, inputParameterList, currentSession, returnTypeWanted, out error);
                }
                if ((responseParameters != null) && (res is IResponseWithOutput))
                {
                    ((IResponseWithOutput)res).SetOutputParameters(responseParameters);
                }
                SuccessResponse(res, error);
            }
            else
            {
                SecurityFailureResponse(res);
            }

            return(res);
        }
Beispiel #5
0
 public GetIndivaulsDataContract(IRacoonResponse toClone)
 {
     base.CloneToPopulate(toClone);
 }
Beispiel #6
0
 public TaskOntologyResponse(IRacoonResponse simple) : this()
 {
     this.AuthorisationOK = simple.AuthorisationOK;
     this.Error           = simple.Error;
     this.Status          = simple.Status;
 }
Beispiel #7
0
 public TaskOntologyResponse(IRacoonResponse simple) : this()
 {
     base.CloneToPopulate(simple);
 }
Beispiel #8
0
 public void CloneToPopulate(IRacoonResponse toClone)
 {
     this.AuthorisationOK = toClone.AuthorisationOK;
     this.Error           = toClone.Error;
     this.Status          = toClone.Status;
 }
 internal static void SecurityFailureResponse(IRacoonResponse res)
 {
     res.AuthorisationOK = false;
     res.Status          = false;
     res.Error           = new System.Security.SecurityException("Session invalid or not found");
 }
 /*  /// <summary>
  * /// Merely checks the validly of a token then discards it. Not ideally for high frequency calls, but good before embarking on long running processing.
  * /// </summary>
  * /// <param name="token"></param>
  * /// <returns></returns>
  * public static SimpleRacoonResponse AurthenticateOnly(byte[] token)
  * {
  *    SimpleRacoonResponse res = new SimpleRacoonResponse();
  *    Session currentSession;
  *    if (SessionStore.TryGetValidSession(token, out currentSession))
  *    {
  *        SuccessResponse(res, null);
  *    }
  *    else
  *    {
  *        SecurityFailureResponse(res);
  *    }
  *
  *    return res;
  * }
  */
 internal static void SuccessResponse(IRacoonResponse res, Exception error)
 {
     res.AuthorisationOK = true;
     res.Error           = error;
     res.Status          = error == null;
 }
Beispiel #11
0
 public GetClassesByFreeTextDataContract(IRacoonResponse toClone)
 {
     base.CloneToPopulate(toClone);
 }