Skip to content

Commit

Permalink
Updates to the PowerShell Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewste committed Mar 16, 2013
1 parent c196df3 commit 598be5e
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 24 deletions.
15 changes: 14 additions & 1 deletion Open Source Automation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Phidget-Servo", "Plugins\OS
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "OSAE.CM17A", "Plugins\OSAE.CM17A\OSAE.CM17A.vbproj", "{CF1B4209-042D-4D9C-8938-ACA00DB19D73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSAE.PowerShell", "Plugins\OSAE.PowerShellProcessor\OSAE.PowerShell.csproj", "{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -596,6 +598,16 @@ Global
{CF1B4209-042D-4D9C-8938-ACA00DB19D73}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CF1B4209-042D-4D9C-8938-ACA00DB19D73}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CF1B4209-042D-4D9C-8938-ACA00DB19D73}.Release|x86.ActiveCfg = Release|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Debug|x86.ActiveCfg = Debug|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Release|Any CPU.Build.0 = Release|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -637,11 +649,12 @@ Global
{74996739-C66D-44CB-8DB5-F6B528395133} = {CC992324-4B93-4E9B-9A2F-AF1D06833965}
{5588C2A8-53CF-4771-9782-4E4CB6AAE3B7} = {CC992324-4B93-4E9B-9A2F-AF1D06833965}
{CF1B4209-042D-4D9C-8938-ACA00DB19D73} = {CC992324-4B93-4E9B-9A2F-AF1D06833965}
{5BAEF1F3-5BE7-4D0B-BBBA-7459B3D3F79B} = {CC992324-4B93-4E9B-9A2F-AF1D06833965}
{08842DAA-31EA-49D2-A613-865C83A63386} = {0C37D9E4-EE97-4740-A811-710B2D0BBF8E}
{C7FA0920-78D8-4C6E-9055-A9E0421E6438} = {0C37D9E4-EE97-4740-A811-710B2D0BBF8E}
{E53124A5-CEC6-40F5-BB01-89D280AD22E9} = {2A452081-FFE5-43C4-82D1-7202917BC509}
{770F99D6-26C6-495A-905D-0EA3ACC5D5D2} = {2A452081-FFE5-43C4-82D1-7202917BC509}
{318EC31C-54EF-4138-A837-E6B0E0EE39BA} = {2A452081-FFE5-43C4-82D1-7202917BC509}
{E53124A5-CEC6-40F5-BB01-89D280AD22E9} = {2A452081-FFE5-43C4-82D1-7202917BC509}
{B1ECF3AD-57BE-4F79-9AEA-0DB153117AEB} = {2A452081-FFE5-43C4-82D1-7202917BC509}
{503092C1-23FE-4AD8-B855-CF1D24D632A9} = {2A452081-FFE5-43C4-82D1-7202917BC509}
{66385FF8-1FF8-4495-B1BF-81A963855517} = {2A452081-FFE5-43C4-82D1-7202917BC509}
Expand Down
4 changes: 2 additions & 2 deletions Plugins/OSAE.CM15A/OSAE.CM15A.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Imports MySql.Data.MySqlClient
Imports ActiveHomeScriptLib
Imports System.AddIn
Imports OpenSourceAutomation
<AddIn("CM15A", Version:="1.0.2")>

Public Class CM15A
Inherits OSAEPluginBase
Structure Device
Expand Down Expand Up @@ -48,7 +48,7 @@ Public Class CM15A
If curTime > gTimeCounter Then booBlockDups = False
End If
Catch myerror As Exception
Logging.AddToLog("Error ActiveHome_RecvAction 1: " & myerror.Message, True)
logging.AddToLog("Error ActiveHome_RecvAction 1: " & myerror.Message, True)
Exit Sub
End Try
Try
Expand Down
1 change: 0 additions & 1 deletion Plugins/OSAE.DSC Alarm/DSC Alarm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Imports System.IO.Ports
Imports System.Threading.Thread
'Imports System.Text.RegularExpressions

<AddIn("DSC Alarm", Version:="0.1.4")>
Public Class DSCAlarm
Inherits OSAEPluginBase
Private Shared logging As Logging = logging.GetLogger("DSC Alarm")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\output\</OutputPath>
<OutputPath>..\..\output\Plugins\PowerShell\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -61,9 +61,20 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="install.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Powershell README.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Screenshot.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="PowerShell.osapd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
6 changes: 3 additions & 3 deletions Plugins/OSAE.PowerShellProcessor/PowerShell.osapd
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin-description xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="3.0">
<plugin-name>Powershell Script Processor</plugin-name>
<plugin-name>PowerShell</plugin-name>
<plugin-id>ee8cea7f-affe-4085-a151-2f8d3d1b86f1</plugin-id>
<plugin-version>1.0.0.0</plugin-version>
<plugin-version>0.0.0.1</plugin-version>
<plugin-state>alpha</plugin-state>
<short-description>
Allows OSA Scripts to be processed by PowerShell</short-description>
<author>Matthew Stebbings</author>
<destination-folder></destination-folder>
<destination-folder>PowerShell</destination-folder>
<main-file></main-file>
<wiki-url>
http://www.opensourceautomation.com/wiki/index.php?title=Power_Shell_Tools</wiki-url>
Expand Down
33 changes: 20 additions & 13 deletions Plugins/OSAE.PowerShellProcessor/PowerShellPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,31 @@ public override void ProcessCommand(OSAEMethod method)
/// <param name="script">The script to be run</param>
private void RunScript(string script)
{
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
try
{
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();

Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(script);
pipeline.Commands.Add("Out-String");
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(script);
pipeline.Commands.Add("Out-String");

Collection<PSObject> results = pipeline.Invoke();
Collection<PSObject> results = pipeline.Invoke();

StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.ToString());
}
StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.ToString());
}

logging.AddToLog("Script return: " + stringBuilder.ToString(), false);
logging.AddToLog("Script return: " + stringBuilder.ToString(), false);

runspace.Close();
runspace.Close();
}
catch (Exception ex)
{
logging.AddToLog("An error occured while trying to run the script, details: \r\n" + ex.Message, true);
}
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions Plugins/OSAE.PowerShellProcessor/install.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CALL osae_sp_object_type_add ('PowerShell','PowerShell Plugin','','PLUGIN',1,0,0,0);
CALL osae_sp_object_type_add ('PowerShell','PowerShell Script Processor','','PLUGIN',0,0,0,1);
CALL osae_sp_object_type_state_add ('ON','Running','PowerShell');
CALL osae_sp_object_type_state_add ('OFF','Stopped','PowerShell');
CALL osae_sp_object_type_event_add ('ON','Started','PowerShell');
CALL osae_sp_object_type_event_add ('OFF','Stopped','PowerShell');
CALL osae_sp_object_type_method_add ('ON','Start','PowerShell','','','','');
CALL osae_sp_object_type_method_add ('OFF','Stop','PowerShell','','','','');
CALL osae_sp_script_processor_add ('PowerShell','PowerShell');
CALL osae_sp_script_processor_add ('PowerShell','PowerShell');
CALL osae_sp_object_type_property_add ('System Plugin','Boolean','TRUE','PowerShell',0);
2 changes: 1 addition & 1 deletion WebUI/objects.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<label>Container</label>
</div>
<div class="span5" style="text-align:left;">
<asp:DropDownList runat="server" ID="ddlContainer" title="The container to which the object will be associated" datatextfield="Text" datavaluefield="Value" style="width:280px;">
<asp:DropDownList runat="server" ID="ddlContainer" datatextfield="Text" datavaluefield="Value" style="width:280px;">
<asp:ListItem Selected = "True" Text = "" Value = ""></asp:ListItem>
</asp:DropDownList>
</div>
Expand Down

0 comments on commit 598be5e

Please sign in to comment.