So i was been creating activities for uipath from now 5-6 months or so with the old method , manually creating a .netframework project and adding all the input and output arguments for the activity
now as Activity Creator is better way to create custom activity i thought to give it a chance, but i dont know why im unable to publish it , im getting this error
|Severity|Code|Description|Project|File|Line|Suppression State|
|---|---|---|---|---|---|---|
|Error||Could not find a part of the path 'C:\Users\HP\source\repos\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations.Activities.Design\obj\Debug\net6.0-windows\IndieDev91.DateTimeOperations.Activities.Design_jassvpr0_wpftmp.GeneratedMSBuildEditorConfig.editorconfig'.|IndieDev91.DateTimeOperations.Activities.Design|C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targets|190|
I was following this video |
Here is the code from my side in the Activity
protected override async Task<Action<AsyncCodeActivityContext>> ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
{
// Inputs
var timeout = TimeoutMS.Get(context);
var firstDate = FirstDate.Get(context);
var secondDate = SecondDate.Get(context);
// Set a timeout on the execution
var task = ExecuteWithTimeout(context, cancellationToken);
if (await Task.WhenAny(task, Task.Delay(timeout, cancellationToken)) != task) throw new TimeoutException(Resources.Timeout_Error);
int differenceInDays = 0; // Declare outside the try block
//My Code
try
{
// Check if the dates have the same date component
if (firstDate.Date == secondDate.Date)
{
throw new ArgumentException("Both dates have the same date component.");
}
// Calculate the difference in days
var timeDifference = secondDate.Date - firstDate.Date;
differenceInDays = Math.Abs(timeDifference.Days);
}
catch(Exception ex)
{
}
// Outputs
return (ctx) => {
Output.Set(ctx, differenceInDays.ToString());
};
}
the only modicfication that i had made is to add a custom icon for the activity here was the icon i have used
also when i opend the Designer.XAML i was not able to see any disgn view as there was some error , here are the errors
1 :-
Severity Code Description Project File Line Suppression State
Error XDG0008 The name "ActivityIconConverter" does not exist in the namespace "clr-namespace:UiPath.Shared.Activities.Design.Converters". IndieDev91.DateTimeOperations.Activities.Design C:\Users\HP\source\repos\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations.Activities.Design\Designers\GetTimeDiffrenceInDaysDesigner.xaml 17
2:-
Severity Code Description Project File Line Suppression State
Error XDG-0001 The resource "ActivityIconConverter" has an incompatible type. IndieDev91.DateTimeOperations.Activities.Design C:\Users\HP\source\repos\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations.Activities.Design\Designers\GetTimeDiffrenceInDaysDesigner.xaml 22
3:-
Severity Code Description Project File Line Suppression State
Error XDG0008 The name "ActivityDecoratorControl" does not exist in the namespace "clr-namespace:UiPath.Shared.Activities.Design.Controls". IndieDev91.DateTimeOperations.Activities.Design C:\Users\HP\source\repos\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations.Activities.Design\Designers\GetTimeDiffrenceInDaysDesigner.xaml 25
4:-
Severity Code Description Project File Line Suppression State
Error Could not find a part of the path 'C:\Users\HP\source\repos\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations\IndieDev91.DateTimeOperations.Activities.Design\obj\Debug\net6.0-windows\IndieDev91.DateTimeOperations.Activities.Design_3v41hkt2_wpftmp.GeneratedMSBuildEditorConfig.editorconfig'. IndieDev91.DateTimeOperations.Activities.Design C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targets 190
and here is the Designer.xaml code
<sap:ActivityDesigner x:Class="IndieDev91.DateTimeOperations.Activities.Design.Designers.GetTimeDiffrenceInDaysDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:activity="clr-namespace:IndieDev91.DateTimeOperations.Activities.Properties;assembly=IndieDev91.DateTimeOperations.Activities"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"
xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"
xmlns:converters="clr-namespace:UiPath.Shared.Activities.Design.Converters"
xmlns:uip="clr-namespace:UiPath.Shared.Activities.Design.Controls">
<sap:ActivityDesigner.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\Themes\Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
<sapc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
<converters:ActivityIconConverter x:Key="ActivityIconConverter" />
</ResourceDictionary>
</sap:ActivityDesigner.Resources>
<sap:ActivityDesigner.Icon>
<DrawingBrush Stretch="Uniform" Drawing="{Binding Path=ModelItem, Converter={StaticResource ActivityIconConverter}, ConverterParameter=pack://application:\,\,\,/IndieDev91.DateTimeOperations.Activities.Design;component/themes/icons.xaml}" />
</sap:ActivityDesigner.Icon>
<uip:ActivityDecoratorControl Style="{StaticResource ActivityDecoratorStyle}">
<Grid Width="300">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="{x:Static activity:Resources.GetTimeDiffrenceInDays_FirstDate_DisplayName}" Grid.Row="0"
ToolTip="{x:Static activity:Resources.GetTimeDiffrenceInDays_FirstDate_Description}"/>
<sapv:ExpressionTextBox Grid.Row="1" ExpressionType="{Binding ModelItem.Properties[FirstDate].PropertyType.GenericTypeArguments[0]}" OwnerActivity="{Binding Path=ModelItem}" HintText="{x:Static activity:Resources.GetTimeDiffrenceInDays_FirstDate_Description}" UseLocationExpression="False">
<sapv:ExpressionTextBox.Expression>
<Binding Path="ModelItem.FirstDate" Converter="{StaticResource ArgumentToExpressionConverter}" Mode="TwoWay" ConverterParameter="In" UpdateSourceTrigger="PropertyChanged" />
</sapv:ExpressionTextBox.Expression>
</sapv:ExpressionTextBox>
<Label Content="{x:Static activity:Resources.GetTimeDiffrenceInDays_SecondDate_DisplayName}" Grid.Row="2"
ToolTip="{x:Static activity:Resources.GetTimeDiffrenceInDays_SecondDate_Description}"/>
<sapv:ExpressionTextBox Grid.Row="3" ExpressionType="{Binding ModelItem.Properties[SecondDate].PropertyType.GenericTypeArguments[0]}" OwnerActivity="{Binding Path=ModelItem}" HintText="{x:Static activity:Resources.GetTimeDiffrenceInDays_SecondDate_Description}" UseLocationExpression="False">
<sapv:ExpressionTextBox.Expression>
<Binding Path="ModelItem.SecondDate" Converter="{StaticResource ArgumentToExpressionConverter}" Mode="TwoWay" ConverterParameter="In" UpdateSourceTrigger="PropertyChanged" />
</sapv:ExpressionTextBox.Expression>
</sapv:ExpressionTextBox>
</Grid>
</uip:ActivityDecoratorControl>
</sap:ActivityDesigner>