Skip to content

Commit

Permalink
FTP: Fixed viewmodel issues (72176, 72177, 72178)
Browse files Browse the repository at this point in the history
STUD-72176, STUD-72177, STUD-72178
  • Loading branch information
alexandru-petre committed Oct 14, 2024
1 parent 936e981 commit 5c9a7be
Show file tree
Hide file tree
Showing 27 changed files with 365 additions and 672 deletions.
17 changes: 12 additions & 5 deletions Activities/Activities.FTP.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30621.155
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UiPath.FTP", "FTP\UiPath.FTP\UiPath.FTP.csproj", "{E9137637-B657-4C22-85A5-2E30ADF82566}"
EndProject
Expand All @@ -19,10 +19,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
FTP\FTP.build.props = FTP\FTP.build.props
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UiPath.Shared.Activities", "Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.shproj", "{4E20C041-2F59-408E-ADB3-0BCFAB48DE61}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UiPath.Shared", "Shared\UiPath.Shared\UiPath.Shared.shproj", "{2E040804-8ED9-4FB8-BB8A-4A38479E2A9E}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{fdfc92ee-090c-4e23-9422-f90eb94c43dd}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -55,4 +56,10 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5AC55779-EA32-41AD-BAAD-1808F8A412CB}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared\UiPath.Shared\UiPath.Shared.projitems*{2e040804-8ed9-4fb8-bb8a-4a38479e2a9e}*SharedItemsImports = 13
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{4e20c041-2f59-408e-adb3-0bcfab48de61}*SharedItemsImports = 13
Shared\UiPath.Shared.Activities\UiPath.Shared.Activities.projitems*{fdfc92ee-090c-4e23-9422-f90eb94c43dd}*SharedItemsImports = 5
Shared\UiPath.Shared\UiPath.Shared.projitems*{fdfc92ee-090c-4e23-9422-f90eb94c43dd}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UiPath.FTP.Activities.Properties;
using UiPath.FTP.Activities.Properties;

namespace UiPath.FTP.Activities.Design.Properties
{
Expand Down
62 changes: 0 additions & 62 deletions Activities/FTP/UiPath.FTP.Activities/Localization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,66 +54,4 @@ public override string Description
}
}
}

public class LocalizedEnum
{
public string Name { get; private set; }
public Enum Value { get; private set; }

protected internal LocalizedEnum(string name, Enum value)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException(nameof(name));
}
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}

Name = name;
Value = value;
}

/// <summary>
/// Method that returns a localized enum with the description as a name, if the description exists.
/// </summary>
/// <param name="enumType"></param>
/// <param name="value"></param>
/// <returns></returns>
public static LocalizedEnum GetLocalizedValue(Type enumType, object value)
{
var name = enumType.GetEnumName(value);
var field = enumType.GetField(name);
DescriptionAttribute descriptionAttribute = field?.GetCustomAttribute<DescriptionAttribute>();

return new LocalizedEnum(descriptionAttribute?.Description ?? name, value as Enum);
}
}

public class LocalizedEnum<T> : LocalizedEnum
{
protected LocalizedEnum(string name, Enum value) : base(name, value)
{
}

public static List<LocalizedEnum> GetLocalizedValues()
{
List<LocalizedEnum> localizedValues = new List<LocalizedEnum>();

Type enumType = typeof(T);
Array enumValues = Enum.GetValues(enumType);

foreach (Enum value in enumValues)
{
string name = enumType.GetEnumName(value);
FieldInfo field = enumType.GetField(name);
DescriptionAttribute descriptionAttribute = field?.GetCustomAttribute<DescriptionAttribute>();

localizedValues.Add(new LocalizedEnum(descriptionAttribute?.Description ?? name, value));
}

return localizedValues;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UiPath.Shared;

//NOTE: This class was taken from Activities repo
namespace UiPath.FTP.Activities.NetCore
Expand Down Expand Up @@ -90,7 +91,7 @@ public void BuildAndInsertMenuActions()
};
foreach (var propertyInfo in _properties.Where(pi => pi != targetPropertyInfo))
{


propertyInfo.Property.AddMenuAction(menuAction);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
using System.Activities.DesignViewModels;
using System.Activities.ViewModels;
using System.Threading.Tasks;
using UiPath.FTP.Activities.NetCore.ViewModels;

namespace UiPath.FTP.Activities
{
/// <summary>
/// Removes a specified file from an FTP server.
/// </summary>
[ViewModelClass(typeof(DeleteViewModel))]
public partial class Delete
{
}
}
using UiPath.FTP.Activities.Properties;

namespace UiPath.FTP.Activities.NetCore.ViewModels
{
Expand All @@ -29,24 +17,12 @@ public DeleteViewModel(IDesignServices services) : base(services)
/// <summary>
/// The path of the file that is to be removed from the FTP server.
/// </summary>
public DesignInArgument<string> RemotePath { get; set; } = new DesignInArgument<string>();
public DesignInArgument<string> RemotePath { get; set; }

protected override void InitializeModel()
{
base.InitializeModel();

RemotePath.IsPrincipal = true;
RemotePath.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };
}

protected override async ValueTask InitializeModelAsync()
{
await base.InitializeModelAsync();
}

protected override void InitializeRules()
{
base.InitializeRules();
PersistValuesChangedDuringInit();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
using System.Activities.DesignViewModels;
using System.Activities.ViewModels;
using System.Threading.Tasks;
using UiPath.FTP.Activities.NetCore.ViewModels;

namespace UiPath.FTP.Activities
{
/// <summary>
/// Checks whether a certain directory exists on an FTP server.
/// </summary>
[ViewModelClass(typeof(DirectoryExistsViewModel))]
public partial class DirectoryExists
{
}
}

namespace UiPath.FTP.Activities.NetCore.ViewModels
{
Expand All @@ -29,34 +16,22 @@ public DirectoryExistsViewModel(IDesignServices services) : base(services)
/// <summary>
/// The path of the FTP directory in which to check whether the indicated directory exists.
/// </summary>
public DesignInArgument<string> RemotePath { get; set; } = new DesignInArgument<string>();
public DesignInArgument<string> RemotePath { get; set; }

/// <summary>
/// A boolean variable that states whether the indicated directory was found or not.
/// </summary>
public DesignOutArgument<bool> Exists { get; set; } = new DesignOutArgument<bool>();
public DesignOutArgument<bool> Exists { get; set; }

protected override void InitializeModel()
{
base.InitializeModel();
PersistValuesChangedDuringInit();

int propertyOrderIndex = 1;

RemotePath.IsPrincipal = true;
RemotePath.OrderIndex = propertyOrderIndex++;
RemotePath.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };

Exists.IsPrincipal = false;
Exists.OrderIndex = propertyOrderIndex++;
}

protected override async ValueTask InitializeModelAsync()
{
await base.InitializeModelAsync();
}

protected override void InitializeRules()
{
base.InitializeRules();
Exists.OrderIndex = propertyOrderIndex;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
using System.Activities.DesignViewModels;
using System.Activities.ViewModels;
using System.Threading.Tasks;
using UiPath.FTP.Activities.NetCore.ViewModels;

namespace UiPath.FTP.Activities
{
/// <summary>
/// Downloads the specified files from an FTP server to the specified local folder.
/// </summary>
[ViewModelClass(typeof(DownloadFilesViewModel))]
public partial class DownloadFiles
{
}
}

namespace UiPath.FTP.Activities.NetCore.ViewModels
{
Expand All @@ -29,59 +16,40 @@ public DownloadFilesViewModel(IDesignServices services) : base(services)
/// <summary>
/// The path of the files on the FTP server that are to be downloaded.
/// </summary>
public DesignInArgument<string> RemotePath { get; set; } = new DesignInArgument<string>();
public DesignInArgument<string> RemotePath { get; set; }

/// <summary>
/// The local path for the files that are to be downloaded.
/// </summary>
public DesignInArgument<string> LocalPath { get; set; } = new DesignInArgument<string>();
public DesignInArgument<string> LocalPath { get; set; }

/// <summary>
/// If this box is checked, the folders will be downloaded with their respective subfolders.
/// </summary>
public DesignProperty<bool> Recursive { get; set; } = new DesignProperty<bool>();
public DesignProperty<bool> Recursive { get; set; }

/// <summary>
/// If this box is checked, the folder path will be created locally in case it does not already exist.
/// </summary>
public DesignProperty<bool> Create { get; set; } = new DesignProperty<bool>();
public DesignProperty<bool> Create { get; set; }

/// <summary>
/// If this box is checked, the files will be overwritten locally if they're already stored there.
/// </summary>
public DesignProperty<bool> Overwrite { get; set; } = new DesignProperty<bool>();
public DesignProperty<bool> Overwrite { get; set; }

protected override void InitializeModel()
{
base.InitializeModel();
PersistValuesChangedDuringInit();

int propertyOrderIndex = 1;

RemotePath.IsPrincipal = true;
RemotePath.OrderIndex = propertyOrderIndex++;
RemotePath.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };

LocalPath.IsPrincipal = true;
LocalPath.OrderIndex = propertyOrderIndex++;
LocalPath.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };

Create.OrderIndex = propertyOrderIndex++;
Create.Widget = new DefaultWidget { Type = ViewModelWidgetType.Toggle };

Recursive.OrderIndex = propertyOrderIndex++;
Recursive.Widget = new DefaultWidget { Type = ViewModelWidgetType.Toggle };

Overwrite.OrderIndex = propertyOrderIndex++;
Overwrite.Widget = new DefaultWidget { Type = ViewModelWidgetType.Toggle };
}

protected override async ValueTask InitializeModelAsync()
{
await base.InitializeModelAsync();
}

protected override void InitializeRules()
{
base.InitializeRules();
Overwrite.OrderIndex = propertyOrderIndex;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
using System.Threading.Tasks;
using UiPath.FTP.Activities.NetCore.ViewModels;

namespace UiPath.FTP.Activities
{
/// <summary>
/// Generates a DataTable variable that contains a list comprising the files found at the specified FTP server path.
/// </summary>
[ViewModelClass(typeof(EnumerateObjectsViewModel))]
public partial class EnumerateObjects
{
}
}

namespace UiPath.FTP.Activities.NetCore.ViewModels
{
Expand All @@ -29,42 +19,30 @@ public EnumerateObjectsViewModel(IDesignServices services) : base(services)
/// <summary>
/// The path of the directory on the FTP server whose files are to be enumerated.
/// </summary>
public DesignInArgument<string> RemotePath { get; set; } = new DesignInArgument<string>();
public DesignInArgument<string> RemotePath { get; set; }

/// <summary>
/// If this check box is selected, the subfolders are also included in the enumeration of the files on the FTP server.
/// </summary>
public DesignProperty<bool> Recursive { get; set; } = new DesignProperty<bool>();
public DesignProperty<bool> Recursive { get; set; }

/// <summary>
/// A collection of files that have been found on the FTP server.
/// </summary>
public DesignOutArgument<System.Collections.Generic.IEnumerable<FtpObjectInfo>> Files { get; set; } = new DesignOutArgument<System.Collections.Generic.IEnumerable<FtpObjectInfo>>();
public DesignOutArgument<System.Collections.Generic.IEnumerable<FtpObjectInfo>> Files { get; set; }

protected override void InitializeModel()
{
base.InitializeModel();
PersistValuesChangedDuringInit();

int propertyOrderIndex = 1;

RemotePath.IsPrincipal = true;
RemotePath.OrderIndex = propertyOrderIndex++;
RemotePath.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };

Files.OrderIndex = propertyOrderIndex++;
Files.Widget = new DefaultWidget { Type = ViewModelWidgetType.Input };
Recursive.OrderIndex = propertyOrderIndex;

Recursive.OrderIndex = propertyOrderIndex++;
Recursive.Widget = new DefaultWidget { Type = ViewModelWidgetType.Toggle };
}

protected override async ValueTask InitializeModelAsync()
{
await base.InitializeModelAsync();
}

protected override void InitializeRules()
{
base.InitializeRules();
}
}
}
Loading

0 comments on commit 5c9a7be

Please sign in to comment.