Example #1
0
 private void MakeProcedure(int procedureTime, IAnimal animal, IProcedure procedure)
 {
     if (!this.procedures.ContainsKey(procedure.GetType().Name))
     {
         this.procedures.Add(procedure.GetType().Name, new List <IAnimal>());
     }
     procedure.DoService(animal, procedureTime);
     this.procedures[procedure.GetType().Name].Add(animal);
 }
Example #2
0
 private void AddProcedure(IProcedure current, IRobot robot)
 {
     if (this.procedures.ContainsKey(current.GetType().Name))
     {
         this.procedures[current.GetType().Name].Add(robot);
     }
     else
     {
         this.procedures[current.GetType().Name] = new List <IRobot>();
         this.procedures[current.GetType().Name].Add(robot);
     }
 }
Example #3
0
        public long ExecuteNonQuery(
            IProcedure procedure,
            ICommand command,
            int timeoutSeconds,
            SQLiteConnection connection,
            SQLiteTransaction transaction)
        {
            if (procedure == null)
            {
                return(0);
            }

            var adoProcedure = procedure as IAdoProcedure;

            if (adoProcedure != null)
            {
                if (timeoutSeconds == 0)
                {
                    return(ExecuteNonQuery(adoProcedure, command, connection, transaction));
                }

                return(ExecuteNonQuery(adoProcedure, command, timeoutSeconds, connection, transaction));
            }

            var nativeProcedure = procedure as INativeProcedure;

            if (nativeProcedure != null)
            {
                throw new NotImplementedException("Procedures that access the SQLite engine natively are not supported in this version");
            }

            throw new PriusException("Unknown procedure type '" + procedure.GetType().FullName + "'");
        }
Example #4
0
        private void SetOutputParameters(SqlParameterCollection parameters, IProcedure procedure)
        {
            Type procType = procedure.GetType();

            PropertyInfo[] properties = procType.GetProperties();
            properties = properties.Where(x => x.GetCustomAttribute <ParameterAttribute>() != null).ToArray();
            foreach (SqlParameter parameter in parameters)
            {
                if (parameter.Direction != ParameterDirection.Input)
                {
                    PropertyInfo property = properties.FirstOrDefault(x => x.GetCustomAttribute <ParameterAttribute>().Name == parameter.ParameterName);
                    property.SetValue(procedure, parameter.Value);
                }
            }
        }
Example #5
0
        public IDataReader ExecuteReader(
            IProcedure procedure,
            ICommand command,
            int timeoutSeconds,
            SQLiteConnection connection,
            SQLiteTransaction transaction,
            string dataShapeName,
            Action <IDataReader> closeAction,
            Action <IDataReader> errorAction)
        {
            if (procedure == null)
            {
                return(null);
            }

            var adoProcedure = procedure as IAdoProcedure;

            if (adoProcedure != null)
            {
                if (timeoutSeconds == 0)
                {
                    return(ExecuteReader(adoProcedure, command, connection,
                                         transaction, dataShapeName, closeAction, errorAction));
                }

                return(ExecuteReader(adoProcedure, command, timeoutSeconds, connection,
                                     transaction, dataShapeName, closeAction, errorAction));
            }

            var nativeProcedure = procedure as INativeProcedure;

            if (nativeProcedure != null)
            {
                throw new NotImplementedException("Procedures that access the SQLite engine natively are not supported in this version");
            }

            throw new PriusException("Unknown procedure type '" + procedure.GetType().FullName + "'");
        }
Example #6
0
        private void GetParametersFromProcedure(IProcedure procedure, SqlParameterCollection parameters)
        {
            Type procType = procedure.GetType();

            PropertyInfo[] properties = procType.GetProperties();
            properties = properties.Where(x => x.GetCustomAttribute <ParameterAttribute>() != null).ToArray();
            foreach (PropertyInfo propInfo in properties)
            {
                ParameterAttribute attribute = propInfo.GetCustomAttribute <ParameterAttribute>();
                object             value     = propInfo.GetGetMethod().Invoke(procedure, new object[] { });
                SqlParameter       parameter = new SqlParameter
                {
                    ParameterName = attribute.Name,
                    Value         = value,
                    Direction     = attribute.Direction
                };
                if (attribute.Size != null)
                {
                    parameter.Size = attribute.Size.Value;
                }
                parameters.Add(parameter);
            }
        }
Example #7
0
 public void Reuse(IProcedure procedure)
 {
     if (procedure != null)
     {
         var procedureType = _procedureTypeWrappers.FirstOrDefault(p => p.ProcedureType == procedure.GetType());
         if (procedureType != null)
         {
             procedureType.Pool.Reuse(procedure);
         }
     }
 }