Skip to content

Commit

Permalink
Added global "On update failed"
Browse files Browse the repository at this point in the history
Added global "On update failed" command
Added .editorconfig

See also. https://ketarin.userecho.com/communities/1/topics/40-onerror-global-events
  • Loading branch information
floele committed Mar 9, 2019
1 parent ac918aa commit ef1728e
Show file tree
Hide file tree
Showing 19 changed files with 203 additions and 70 deletions.
101 changes: 101 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]

#Core editorconfig formatting - indentation

#use soft tabs (spaces) for indentation
indent_style = space

#Formatting - indentation options

#indent switch case contents.
csharp_indent_case_contents = true
#indent switch labels
csharp_indent_switch_labels = true

#Formatting - new line options

#place catch statements on a new line
csharp_new_line_before_catch = true
#place else statements on a new line
csharp_new_line_before_else = true
#require finally statements to be on a new line after the closing brace
csharp_new_line_before_finally = true
#require braces to be on a new line for methods, properties, accessors, anonymous_methods, object_collection_array_initializers, types, and control_blocks (also known as "Allman" style)
csharp_new_line_before_open_brace = methods, properties, accessors, anonymous_methods, object_collection_array_initializers, types, control_blocks

#Formatting - organize using options

#sort System.* using directives alphabetically, and place them before other usings
dotnet_sort_system_directives_first = true

#Formatting - spacing options

#require NO space between a cast and the value
csharp_space_after_cast = false
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_after_colon_in_inheritance_clause = true
#require a space after a keyword in a control flow statement such as a for loop
csharp_space_after_keywords_in_control_flow_statements = true
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_before_colon_in_inheritance_clause = true
#remove space within empty argument list parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false
#remove space between method call name and opening parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
csharp_space_between_method_call_parameter_list_parentheses = false
#remove space within empty parameter list parentheses for a method declaration
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
csharp_space_between_method_declaration_parameter_list_parentheses = false

#Formatting - wrapping options

#leave code block on single line
csharp_preserve_single_line_blocks = true
#leave statements and member declarations on the same line
csharp_preserve_single_line_statements = true

#Style - expression bodied member options

csharp_style_expression_bodied_accessors = true:suggestion
#prefer block bodies for constructors
csharp_style_expression_bodied_constructors = false:suggestion
#prefer block bodies for methods
csharp_style_expression_bodied_methods = false:suggestion
#prefer block bodies for properties
csharp_style_expression_bodied_properties = true:suggestion

#Style - expression level options

#prefer out variables to be declared before the method call
csharp_style_inlined_variable_declaration = true:suggestion
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion

#Style - implicit and explicit types

#prefer explicit type over var to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = false:suggestion
#prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration
csharp_style_var_when_type_is_apparent = false:suggestion

#Style - language keyword and framework type options

#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

#Style - qualification options

#prefer events not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_event = false:suggestion
#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer methods not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_method = true:suggestion
#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = true:suggestion

# Modifiers should always be specified
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/bin
/.vs
/packages
*.csproj.user
*.csproj.user
*.cache
12 changes: 7 additions & 5 deletions ApplicationJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,11 @@ public bool TargetIsFolder
}

[XmlElement("TargetPath")]
public string TargetPath {
get { return m_TargetPath; }
set { m_TargetPath = PathEx.FixDirectorySeparator(value); }
}
public string TargetPath
{
get { return m_TargetPath; }
set { m_TargetPath = PathEx.FixDirectorySeparator(value); }
}

[XmlElement("FixedDownloadUrl")]
public string FixedDownloadUrl { get; set; } = string.Empty;
Expand All @@ -707,7 +708,8 @@ public bool TargetIsFolder
public string Name
{
get { return this.m_Name; }
set {
set
{
this.m_Name = value.Length > 255 ? value.Substring(0, 255) : value;
}
}
Expand Down
17 changes: 5 additions & 12 deletions Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
using System.IO;
using System.Text;
using System.Windows.Forms;
using CDBurnerXP;
using Ketarin.Forms;

namespace Ketarin
{
/// <summary>
/// Represents a user command, which can be any kind of scripting language.
/// </summary>
class Command
internal class Command
{
/// <summary>
/// Gets or sets the scripting language.
Expand All @@ -34,19 +35,11 @@ public Command(string text, string type)
this.Type = ConvertToScriptType(type);
}

/// <summary>
/// Executes the command.
/// </summary>
public virtual int Execute(ApplicationJob application)
{
return Execute(application, null);
}

/// <summary>
/// Executes the command.
/// </summary>
/// <param name="targetFileName">Content for variable "{url:...}"</param>
public virtual int Execute(ApplicationJob application, string targetFileName)
public virtual int Execute(ApplicationJob application, string targetFileName = null, ApplicationJobError errorInfo = null)
{
switch (Type)
{
Expand All @@ -57,8 +50,8 @@ public virtual int Execute(ApplicationJob application, string targetFileName)

case ScriptType.PowerShell:
PowerShellScript psScript = new PowerShellScript(this.Text);
psScript.Execute(application);
break;
psScript.Execute(application, errorInfo);
return Conversion.ToInt(psScript.LastOutput);

default:
return ExecuteBatchCommand(application, this.Text, targetFileName);
Expand Down
2 changes: 1 addition & 1 deletion CommandErrorException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Ketarin
/// command returns the code "1" to indicate an error
/// and prevent downloading.
/// </summary>
class CommandErrorException : ApplicationException
internal class CommandErrorException : ApplicationException
{
public CommandErrorException()
: base("The custom command failed (exit code 1), download aborted")
Expand Down
2 changes: 1 addition & 1 deletion DbManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Ketarin
/// This class contains a collection of functions
/// for reading from the database.
/// </summary>
class DbManager
internal class DbManager
{
#region SettingsProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace MyDownloader.Extension.Protocols
{
class HttpFtpProtocolParametersSettingsProxy : IHttpFtpProtocolParameters
internal class HttpFtpProtocolParametersSettingsProxy : IHttpFtpProtocolParameters
{
#region IHttpFtpProtocolParameters Members

Expand Down
2 changes: 1 addition & 1 deletion ExternalServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Ketarin
/// <summary>
/// Provides a couple of functions for external services like FileHippo.
/// </summary>
static class ExternalServices
internal static class ExternalServices
{
/// <summary>
/// If the given URL contains a FileHippo ID, it is returned.
Expand Down
2 changes: 1 addition & 1 deletion Forms/HintTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Ketarin
/// <summary>
/// A text box which displays a gray coloured hint.
/// </summary>
class HintTextBox : PaintableTextBoxBase
internal class HintTextBox : PaintableTextBoxBase
{
private string hintText = string.Empty;
private HorizontalAlign hintTextAlign = HorizontalAlign.Left;
Expand Down
2 changes: 1 addition & 1 deletion Forms/PaintableTextBoxBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Ketarin.Forms
/// <summary>
/// Allows custom drawing within a text box.
/// </summary>
class PaintableTextBoxBase : TextBox
internal class PaintableTextBoxBase : TextBox
{
public new event PaintEventHandler Paint;

Expand Down
37 changes: 19 additions & 18 deletions Forms/SettingsDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Forms/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ private void SaveCurrentCommand()
Settings.SetValue("PostUpdateCommand", this.commandControl.Text);
Settings.SetValue("PostUpdateCommandType", this.commandControl.CommandType.ToString());
break;

case 3:
Settings.SetValue("UpdateFailedCommand", this.commandControl.Text);
Settings.SetValue("UpdateFailedCommandType", this.commandControl.CommandType.ToString());
break;
}
}

Expand Down Expand Up @@ -344,6 +349,11 @@ private void LoadCommand()
this.commandControl.Text = Settings.GetValue("PostUpdateCommand", "") as string;
this.commandControl.CommandType = Command.ConvertToScriptType(Settings.GetValue("PostUpdateCommandType", ScriptType.Batch.ToString()) as string);
break;

case 3:
this.commandControl.Text = Settings.GetValue("UpdateFailedCommand", "") as string;
this.commandControl.CommandType = Command.ConvertToScriptType(Settings.GetValue("UpdateFailedCommandType", ScriptType.Batch.ToString()) as string);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Forms/VariableTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Ketarin.Forms
/// <summary>
/// A usual textbox plus variable selection tool.
/// </summary>
class VariableTextBox : TextBox
internal class VariableTextBox : TextBox
{
private string[] m_VariableNames = new string[0];
private ContextMenuCustomiser m_Customiser;
Expand Down
3 changes: 2 additions & 1 deletion Ketarin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include=".editorconfig" />
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
Expand Down Expand Up @@ -669,4 +670,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
2 changes: 1 addition & 1 deletion NonBinaryFileException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Ketarin
/// This exception should be thrown, if the file to download is
/// not a binary file type.
/// </summary>
class NonBinaryFileException : Exception
internal class NonBinaryFileException : Exception
{
private static string m_Message = "The downloaded file is not a binary file type ({0}). Possibly there is an error page. Status code: {1} ({2})";

Expand Down
Loading

0 comments on commit ef1728e

Please sign in to comment.