Beispiel #1
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (PSProvider.Expression != null)
            {
                targetCommand.AddParameter("PSProvider", PSProvider.Get(context));
            }

            if (PSDrive.Expression != null)
            {
                targetCommand.AddParameter("PSDrive", PSDrive.Get(context));
            }

            if (Stack.Expression != null)
            {
                targetCommand.AddParameter("Stack", Stack.Get(context));
            }

            if (StackName.Expression != null)
            {
                targetCommand.AddParameter("StackName", StackName.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Beispiel #2
0
        public async Task <IActionResult> PutPSDriveInfo([FromRoute] int id, [FromBody] PSDrive pSDriveInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pSDriveInfo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(pSDriveInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PSDriveInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
        public async Task <IActionResult> PostPSDriveInfo([FromBody] PSDrive pSDriveInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PSDrives.Add(pSDriveInfo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPSDriveInfo", new { id = pSDriveInfo.Id }, pSDriveInfo));
        }