示例#1
0
        public async Task <PagedList <Region> > GetAll(EntityParameters entityParameters)
        {
            var regions = await _context.Regions.ToListAsync();

            return(PagedList <Region>
                   .ToPagedList(regions, entityParameters.PageNumber, entityParameters.PageSize));
        }
示例#2
0
        public async Task <IActionResult> GetAll([FromQuery] EntityParameters entityParameters)
        {
            var regions = await _regionRepo.GetAll(entityParameters);

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(regions.MetaData));
            return(Ok(regions));
        }
        //passing an entire URI to the server endpoint
        public async Task <PagingResponse <Apartment> > GetAll(EntityParameters entityParameters)
        {
            var queryStringParam = new Dictionary <string, string>
            {
                ["pageNumber"] = entityParameters.PageNumber.ToString(),
                ["searchTerm"] = entityParameters.SearchTerm ?? "",
                ["orderBy"]    = entityParameters.OrderBy
            };

            var response = await _client.GetAsync(QueryHelpers.AddQueryString("https://localhost:5021/api/apartments", queryStringParam));

            var content = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw new ApplicationException(content);
            }

            var pagingResponse = new PagingResponse <Apartment>
            {
                Items = JsonSerializer.Deserialize <List <Apartment> >(content, new JsonSerializerOptions {
                    PropertyNameCaseInsensitive = true
                }),
                MetaData = JsonSerializer.Deserialize <MetaData>(response.Headers.GetValues("X-Pagination").First(), new JsonSerializerOptions {
                    PropertyNameCaseInsensitive = true
                })
            };

            return(pagingResponse);
        }
        public EntityParameters <MySqlParameter> GetUpdateParameters(object entity)
        {
            EntityUpdateParameters = EntityUpdateParameters ?? CreateEntityParameters(entity, false);

            EntityUpdateParameters.FillParameters(entity, FillInsertParameters);

            return(EntityUpdateParameters);
        }
示例#5
0
        /// <summary>
        /// Destroys the simulation.
        /// </summary>
        protected virtual void Unsetup()
        {
            // Clear all parameters
            EntityBehaviors.Clear();
            EntityBehaviors = null;
            EntityParameters.Clear();
            EntityParameters = null;

            // Clear all nodes
            Variables.Clear();
            Variables = null;
        }
示例#6
0
        public async Task <PagedList <Apartment> > GetAll(EntityParameters entityParameters)
        {
            var apartments = await _context.Apartments
                             .Include(a => a.Region)
                             .Search(entityParameters.SearchTerm)
                             .Sort(entityParameters.OrderBy)
                             .ToListAsync();


            return(PagedList <Apartment>
                   .ToPagedList(apartments, entityParameters.PageNumber, entityParameters.PageSize));
        }
示例#7
0
        public async Task <PagedList <House> > GetAll(EntityParameters entityParameters)
        {
            var houses = await _context.Houses
                         .Include(h => h.Region)
                         .Search(entityParameters.SearchTerm)
                         .Sort(entityParameters.OrderBy)
                         .ToListAsync();


            return(PagedList <House>
                   .ToPagedList(houses, entityParameters.PageNumber, entityParameters.PageSize));
        }
        //public List<IDataParameter> DataParameters { get; set; }

        /// <summary>
        /// Create parameters from object properties
        /// </summary>
        /// <param name="parametersType"></param>
        /// <returns></returns>
        public EntityParameters <MySqlParameter> CreateEntityParameters(object entity, bool checkForIdentityColumn)
        {
            var entityParameters = EntityParameters <MySqlParameter> .Create(entity, (o, dataParameters, outParamsDictionary, checkForIdentity) =>
            {
                var entityType = entity.GetType();
                var propertiesForDataParams = entityType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Default);

                foreach (var propertyInfo in propertiesForDataParams)
                {
                    CreateDataParameter(propertyInfo, dataParameters, outParamsDictionary, checkForIdentity);
                }
            }, checkForIdentityColumn);

            return(entityParameters);
        }
示例#9
0
        /// <summary>
        /// Collect and set up the parameter sets of all circuit entities.
        /// </summary>
        /// <remarks>
        /// The parameter sets are cloned during set up to avoid issues when running multiple
        /// simulations in parallel.
        /// </remarks>
        /// <param name="entities">The entities for which parameter sets need to be collected.</param>
        /// <exception cref="ArgumentNullException">entities</exception>
        private void SetupParameters(IEnumerable <Entity> entities)
        {
            entities.ThrowIfNull(nameof(entities));

            // Register all parameters
            foreach (var entity in entities)
            {
                foreach (var p in entity.ParameterSets.Values)
                {
                    var parameterset = _cloneParameters ? p.Clone() : p;
                    parameterset.CalculateDefaults();
                    EntityParameters.Add(entity.Name, parameterset);
                }
            }
        }
示例#10
0
        /// <summary>
        /// Collect and set up the parameter sets of all circuit entities.
        /// </summary>
        /// <remarks>
        /// The parameter sets are cloned during set up to avoid issues when running multiple
        /// simulations in parallel.
        /// </remarks>
        /// <param name="entities">The entities for which parameter sets need to be collected.</param>
        /// <exception cref="ArgumentNullException">entities</exception>
        private void SetupParameters(IEnumerable <Entity> entities)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            // Register all parameters
            foreach (var entity in entities)
            {
                foreach (var p in entity.ParameterSets.Values)
                {
                    p.CalculateDefaults();
                    EntityParameters.Add(entity.Name, _cloneParameters ? p.DeepClone() : p);
                }
            }
        }
 /// <summary>
 /// Load all the properties from DbParameters which were marked as ParameterDirection.Out
 /// </summary>
 /// <param name="entityParameters">The EntityParameters object based on TDataParameters in ISimpleAccess</param>
 /// <param name="instance"> The instance of object </param>
 public void LoadOutParametersProperties(EntityParameters <MySqlParameter> entityParameters, object instance)
 {
     entityParameters.LoadOutParametersProperties(instance);
 }
 /// <summary>
 /// Clear all DbParamters
 /// </summary>
 public void ClearDbParameters()
 {
     EntityInsertParameters = null;
     EntityUpdateParameters = null;
 }
示例#13
0
文件: DC.cs 项目: slicol/SpiceSharp
        /// <summary>
        /// Execute the DC analysis
        /// </summary>
        protected override void Execute()
        {
            // Base
            base.Execute();

            var exportargs = new ExportDataEventArgs(this);

            // Setup the state
            var state      = RealState;
            var dcconfig   = DcConfiguration;
            var baseconfig = BaseConfiguration;

            state.Init   = RealState.InitializationStates.InitJunction;
            state.UseIc  = false; // UseIC is only used in transient simulations
            state.UseDc  = true;
            state.Domain = RealState.DomainType.None;
            state.Gmin   = baseconfig.Gmin;

            // Initialize
            Sweeps = new NestedSweeps(dcconfig.Sweeps);
            Parameter[] swept    = new Parameter[Sweeps.Count];
            Parameter[] original = new Parameter[Sweeps.Count];
            int         levelNeedsTemperature = -1;

            // Initialize first time
            for (int i = 0; i < dcconfig.Sweeps.Count; i++)
            {
                // Get the component to be swept
                var sweep = Sweeps[i];

                // Try finding the parameter to sweep
                var args = new DCParameterSearchEventArgs(sweep.Parameter, i);
                OnParameterSearch?.Invoke(this, args);

                if (args.Result != null)
                {
                    swept[i] = args.Result;

                    // Keep track of the highest level that needs to recalculate temperature
                    if (args.TemperatureNeeded)
                    {
                        levelNeedsTemperature = Math.Max(levelNeedsTemperature, i);
                    }
                }
                else
                {
                    // Get entity parameters
                    if (!EntityBehaviors.ContainsKey(sweep.Parameter))
                    {
                        throw new CircuitException("Could not find source {0}".FormatString(sweep.Parameter));
                    }
                    var eb = EntityParameters.GetEntityParameters(sweep.Parameter);

                    // Check for a Voltage source or Current source parameters
                    if (eb.TryGet <Components.VoltageSourceBehaviors.BaseParameters>(out var pvsrc))
                    {
                        swept[i] = pvsrc.DcValue;
                    }
                    else if (eb.TryGet <Components.CurrentSourceBehaviors.BaseParameters>(out var pisrc))
                    {
                        swept[i] = pisrc.DcValue;
                    }
                    else
                    {
                        throw new CircuitException("Invalid sweep object");
                    }
                }

                original[i]    = (Parameter)swept[i].Clone();
                swept[i].Value = sweep.Initial;
            }

            // Execute temperature behaviors if necessary the first time
            if (levelNeedsTemperature >= 0)
            {
                for (int i = 0; i < TemperatureBehaviors.Count; i++)
                {
                    TemperatureBehaviors[i].Temperature(this);
                }
            }

            // Execute the sweeps
            int level = Sweeps.Count - 1;

            while (level >= 0)
            {
                // Fill the values with start values
                while (level < Sweeps.Count - 1)
                {
                    level++;
                    Sweeps[level].Reset();
                    swept[level].Value = Sweeps[level].CurrentValue;
                    state.Init         = RealState.InitializationStates.InitJunction;
                }

                // Calculate the solution
                if (!Iterate(dcconfig.SweepMaxIterations))
                {
                    IterationFailed?.Invoke(this, EventArgs.Empty);
                    Op(baseconfig.DcMaxIterations);
                }

                // Export data
                Export(exportargs);

                // Remove all values that are greater or equal to the maximum value
                while (level >= 0 && Sweeps[level].CurrentStep >= Sweeps[level].Limit)
                {
                    level--;
                }

                // Go to the next step for the top level
                if (level >= 0)
                {
                    Sweeps[level].Increment();
                    swept[level].Value = Sweeps[level].CurrentValue;

                    // If temperature behavior is needed for this level or higher, run behaviors
                    if (levelNeedsTemperature >= level)
                    {
                        for (int i = 0; i < TemperatureBehaviors.Count; i++)
                        {
                            TemperatureBehaviors[i].Temperature(this);
                        }
                    }
                }
            }

            // Restore all the parameters of the swept components
            for (int i = 0; i < Sweeps.Count; i++)
            {
                swept[i].CopyFrom(original[i]);
            }
        }
示例#14
0
 /// <summary>
 /// Load all the properties from DbParameters which were marked as ParameterDirection.Out
 /// </summary>
 /// <param name="entityParameters">The EntityParameters object based on TDataParameters in ISimpleAccess</param>
 /// <param name="instance"> The instance of object </param>
 public void LoadOutParametersProperties(EntityParameters <TDbParameter> entityParameters, object instance)
 {
     entityParameters.LoadOutParametersProperties(instance);
     //SqlBuilder.LoadOutParametersProperties(instance);
 }