-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
881 additions
and
196 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
modules/Modules.HTML.Actions/ConvertDataTableToHtmlTableAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// -------------------------------------------------------------- | ||
// Copyright (c) Jesus Fernandez. All Rights Reserved. | ||
// -------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Data; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Text; | ||
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK; | ||
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.Attributes; | ||
|
||
namespace PowerAutomate.Desktop.Modules.HTML.Actions; | ||
|
||
[Action(Id = "ConvertDataTableToHtmlTable")] | ||
[Throws(ErrorCodes.Unknown)] | ||
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "UnusedType.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
public class ConvertDataTableToHtmlTableAction : ActionBase | ||
{ | ||
[InputArgument] | ||
public DataTable DataTable { get; set; } = null!; | ||
|
||
[OutputArgument] | ||
public string HtmlTable { get; set; } = null!; | ||
|
||
public override void Execute(ActionContext context) | ||
{ | ||
Debugger.Launch(); | ||
|
||
try | ||
{ | ||
var html = new StringBuilder(); | ||
html.Append("<table>"); | ||
html.Append("<tr>"); | ||
foreach (DataColumn column in DataTable.Columns) | ||
{ | ||
html.Append("<th>").Append(column.ColumnName).Append("</th>"); | ||
} | ||
|
||
html.Append("</tr>"); | ||
|
||
foreach (DataRow row in DataTable.Rows) | ||
{ | ||
html.Append("<tr>"); | ||
foreach (var item in row.ItemArray) | ||
{ | ||
html.Append("<td>").Append(item).Append("</td>"); | ||
} | ||
|
||
html.Append("</tr>"); | ||
} | ||
|
||
html.Append("</table>"); | ||
HtmlTable = html.ToString(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new ActionException(ErrorCodes.Unknown, ex.Message, ex); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
modules/Modules.HTML.Actions/ConvertListToHtmlListAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// -------------------------------------------------------------- | ||
// Copyright (c) Jesus Fernandez. All Rights Reserved. | ||
// -------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Text; | ||
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK; | ||
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.Attributes; | ||
|
||
namespace PowerAutomate.Desktop.Modules.HTML.Actions; | ||
|
||
[Action(Id = "ConvertListToHtmlList")] | ||
[Throws(ErrorCodes.Unknown)] | ||
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
[SuppressMessage("ReSharper", "UnusedType.Global", Justification = "PowerAutomate.Desktop.Module.Action")] | ||
public class ConvertListToHtmlListAction : ActionBase | ||
{ | ||
[OutputArgument(Order = 1)] | ||
public string HtmlList { get; set; } = null!; | ||
|
||
[InputArgument(Order = 0)] | ||
[DefaultValue(false)] | ||
public bool IsOrdered { get; set; } | ||
|
||
[InputArgument(Order = 1)] | ||
public List<object> List { get; set; } = null!; | ||
|
||
public override void Execute(ActionContext context) | ||
{ | ||
Debugger.Launch(); | ||
|
||
try | ||
{ | ||
var rootTag = IsOrdered ? "ol" : "ul"; | ||
var html = new StringBuilder(); | ||
html.Append($"<{rootTag}>"); | ||
foreach (var item in List) | ||
{ | ||
html.Append("<li>").Append(item).Append("</li>"); | ||
} | ||
|
||
html.Append($"</{rootTag}>"); | ||
HtmlList = html.ToString(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw new ActionException(ErrorCodes.Unknown, ex.Message, ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// -------------------------------------------------------------- | ||
// Copyright (c) Jesus Fernandez. All Rights Reserved. | ||
// -------------------------------------------------------------- | ||
|
||
using System.Diagnostics; | ||
|
||
namespace PowerAutomate.Desktop.Modules.HTML.Actions; | ||
|
||
internal static class Debugger | ||
{ | ||
[Conditional("DEBUG")] | ||
public static void Launch() | ||
{ | ||
System.Diagnostics.Debugger.Launch(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// -------------------------------------------------------------- | ||
// Copyright (c) Jesus Fernandez. All Rights Reserved. | ||
// -------------------------------------------------------------- | ||
|
||
namespace PowerAutomate.Desktop.Modules.HTML.Actions; | ||
|
||
internal static class ErrorCodes | ||
{ | ||
public const string Unknown = "UnknownError"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<AssemblyTitle>HTML</AssemblyTitle> | ||
<TargetFramework>net472</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<PackCustomModule Condition=" '$(Configuration)' == 'Debug' ">true</PackCustomModule> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx"> | ||
<Generator>PublicResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.