Skip to content

Commit 9167e9f

Browse files
committed
Adjusted Logic Error Dealing
1 parent 88a7b84 commit 9167e9f

File tree

12 files changed

+485
-6
lines changed

12 files changed

+485
-6
lines changed

.github/workflows/production_actions.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ jobs:
153153
run: |
154154
(Get-Content GltfInstaller/Program.cs) -replace '0.0.0', $env:FULL_VERSION | Out-File -encoding ASCII GltfInstaller/Program.cs
155155
156+
- name: Configuring ClickupEndpoint
157+
run: |
158+
$apiUrl = "${{ secrets.EVERSE_LEIA_Clickup }}"
159+
(Get-Content Common_glTF_Exporter/Utils/ClickUpFormSender.cs) -replace 'ClickupEndPoint', $apiUrl | Out-File -encoding ASCII Common_glTF_Exporter/Utils/ClickUpFormSender.cs
160+
shell: pwsh
161+
156162
- name: Build and Publish App
157163
run: msbuild Revit_glTF_Exporter.sln /t:Clean,Build /p:platform="Any CPU" /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile
158164

Common_glTF_Exporter/Common_glTF_Exporter.projitems

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<Compile Include="$(MSBuildThisFileDirectory)Transform\ModelRotation.cs" />
6565
<Compile Include="$(MSBuildThisFileDirectory)Transform\ModelScale.cs" />
6666
<Compile Include="$(MSBuildThisFileDirectory)Utils\Analytics.cs" />
67+
<Compile Include="$(MSBuildThisFileDirectory)Utils\ClickUpFormSender.cs" />
6768
<Compile Include="$(MSBuildThisFileDirectory)Utils\DirectoryUtils.cs" />
6869
<Compile Include="$(MSBuildThisFileDirectory)Utils\ExportLog.cs" />
6970
<Compile Include="$(MSBuildThisFileDirectory)Utils\Hyperlink.cs" />
@@ -82,6 +83,12 @@
8283
<Compile Include="$(MSBuildThisFileDirectory)Windows\AboutUsWindow.xaml.cs">
8384
<DependentUpon>AboutUsWindow.xaml</DependentUpon>
8485
</Compile>
86+
<Compile Include="$(MSBuildThisFileDirectory)Windows\ErrorReportWindow.xaml.cs">
87+
<DependentUpon>ErrorReportWindow.xaml</DependentUpon>
88+
</Compile>
89+
<Compile Include="$(MSBuildThisFileDirectory)Windows\ErrorWindow.xaml.cs">
90+
<DependentUpon>ErrorWindow.xaml</DependentUpon>
91+
</Compile>
8592
<Compile Include="$(MSBuildThisFileDirectory)Windows\FeedbackWindow.xaml.cs">
8693
<DependentUpon>FeedbackWindow.xaml</DependentUpon>
8794
</Compile>
@@ -145,6 +152,14 @@
145152
<SubType>Designer</SubType>
146153
<Generator>MSBuild:Compile</Generator>
147154
</Page>
155+
<Page Include="$(MSBuildThisFileDirectory)Windows\ErrorReportWindow.xaml">
156+
<SubType>Designer</SubType>
157+
<Generator>MSBuild:Compile</Generator>
158+
</Page>
159+
<Page Include="$(MSBuildThisFileDirectory)Windows\ErrorWindow.xaml">
160+
<SubType>Designer</SubType>
161+
<Generator>MSBuild:Compile</Generator>
162+
</Page>
148163
<Page Include="$(MSBuildThisFileDirectory)Windows\FeedbackWindow.xaml">
149164
<SubType>Designer</SubType>
150165
<Generator>MSBuild:Compile</Generator>

Common_glTF_Exporter/Core/GlTFExportContext.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ public RenderNodeAction OnElementBegin(ElementId elementId)
178178
currentGeometry.Reset();
179179
currentVertices.Reset();
180180

181+
SettingsConfig.UpdatedLastElement(elementId);
181182
return RenderNodeAction.Proceed;
182183
}
183184

@@ -221,11 +222,11 @@ public void OnElementEnd(ElementId elementId)
221222
bufferViews,
222223
kvp.Value,
223224
kvp.Key,
224-
#if REVIT2024 || REVIT2025 || REVIT2026
225+
#if REVIT2024 || REVIT2025 || REVIT2026
225226
elementId.Value,
226-
#else
227+
#else
227228
elementId.IntegerValue,
228-
#endif
229+
#endif
229230
preferences,
230231
mat,
231232
images,

Common_glTF_Exporter/ExternalCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
3939
catch (Exception ex)
4040
{
4141
Analytics.Send("Error", ex.Message).GetAwaiter();
42+
ExportLog.Write($"Last Element Processed {SettingsConfig.lastElement}");
4243
ExportLog.WriteException(ex);
43-
MessageWindow.Show("Error", ex.Message);
44+
ErrorWindow.Show(ex.Message);
4445
return Result.Failed;
4546
}
4647
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Common_glTF_Exporter.Utils;
2+
using System;
3+
using System.IO;
4+
using System.Net.Http;
5+
using System.Net.Http.Headers;
6+
using System.Threading.Tasks;
7+
8+
public static class ClickUpFormSender
9+
{
10+
public static async Task CreateClickUpTask(string email, string errorDescription, string exError)
11+
{
12+
string url = "ClickupEndPoint";
13+
string description = $"{email}\n{errorDescription}\n{exError}";
14+
15+
using (var client = new HttpClient())
16+
{
17+
// Leer el archivo de forma síncrona (compatible con .NET Framework)
18+
byte[] fileBytes = File.ReadAllBytes(ExportLog.logFilePath);
19+
20+
var content = new ByteArrayContent(fileBytes);
21+
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
22+
23+
// Crear el JSON dinámicamente, incluyendo la descripción
24+
string taskJson = $"{{\"name\":\"Bug Report\",\"description\":\"{EscapeJson(description)}\"}}";
25+
26+
// Agregar headers
27+
content.Headers.Add("x-file-name", ExportLog.FileLogName);
28+
content.Headers.Add("x-task-json", taskJson);
29+
30+
try
31+
{
32+
Console.WriteLine("Uploading file...");
33+
HttpResponseMessage response = await client.PostAsync(url, content);
34+
35+
string responseText = await response.Content.ReadAsStringAsync();
36+
Console.WriteLine("Response status: " + response.StatusCode);
37+
Console.WriteLine("Response body: " + responseText);
38+
}
39+
catch (Exception ex)
40+
{
41+
Console.WriteLine("Error: " + ex.Message);
42+
}
43+
}
44+
}
45+
46+
// Escapa caracteres especiales para que no rompan el JSON
47+
private static string EscapeJson(string value)
48+
{
49+
return value
50+
.Replace("\\", "\\\\")
51+
.Replace("\"", "\\\"")
52+
.Replace("\n", "\\n")
53+
.Replace("\r", "\\r");
54+
}
55+
}

Common_glTF_Exporter/Utils/ExportLog.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ namespace Common_glTF_Exporter.Utils
66
{
77
public class ExportLog
88
{
9-
private static readonly string logFilePath = Path.Combine(Links.configDir, "leia_log.txt");
9+
public static readonly string FileLogName = "leia_log.txt";
10+
public static readonly string logFilePath = Path.Combine(Links.configDir, FileLogName);
1011

1112
public static void StartLog()
1213
{

Common_glTF_Exporter/Utils/LogConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static void SaveConfig()
3535
ExportLog.Write($"compression: {compression}");
3636
ExportLog.Write($"release: {release}");
3737
ExportLog.Write($"runs: {runs}");
38+
ExportLog.Write($"LeiaVersion: {SettingsConfig.currentVersion}");
3839
}
3940

4041
}

Common_glTF_Exporter/Utils/SettingsConfig.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Autodesk.Revit.DB;
2+
using System;
23
using System.Collections.Generic;
34
using System.Configuration;
45
using System.IO;
@@ -15,6 +16,7 @@ public static class SettingsConfig
1516
Path.Combine(Links.configDir, "leia.config");
1617

1718
private static readonly object _locker = new object();
19+
public static int lastElement = 0;
1820

1921
static SettingsConfig()
2022
{
@@ -129,5 +131,36 @@ private static void CreateDefaultConfig()
129131

130132
doc.Save(_configFile);
131133
}
134+
135+
public static void UpdatedLastElement(ElementId elementId)
136+
{
137+
try
138+
{
139+
if (elementId == null)
140+
{
141+
lastElement = -1;
142+
return;
143+
}
144+
145+
if (elementId == ElementId.InvalidElementId)
146+
{
147+
lastElement = -1;
148+
return;
149+
}
150+
151+
#if REVIT2024 || REVIT2025 || REVIT2026
152+
153+
long longValue = (long)elementId.Value;
154+
lastElement = Convert.ToInt32(elementId.Value);
155+
156+
#else
157+
lastElement = elementId.IntegerValue;
158+
#endif
159+
}
160+
catch (OverflowException ex)
161+
{
162+
lastElement = -1;
163+
}
164+
}
132165
}
133166
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<Window x:Class="Revit_glTF_Exporter.ErrorReportWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Revit_glTF_Exporter"
7+
mc:Ignorable="d"
8+
WindowStartupLocation="CenterScreen"
9+
Title="Exporting process in progress..."
10+
Height="335"
11+
Width="357"
12+
ResizeMode="NoResize"
13+
Topmost="True"
14+
ShowInTaskbar="True"
15+
Style="{DynamicResource CustomWindowStyle}">
16+
17+
18+
<Border Background="{DynamicResource BackgroundColor}"
19+
BorderBrush="Transparent"
20+
BorderThickness="1,1,1,1"
21+
CornerRadius="8,8,8,8"
22+
MouseDown="Border_MouseDown" Margin="15,5,13,15">
23+
<Border.Effect>
24+
<DropShadowEffect BlurRadius="20" Color="Gray" Opacity="0.3" ShadowDepth="0" Direction="0"></DropShadowEffect>
25+
</Border.Effect>
26+
27+
<Grid
28+
Background="Transparent" Margin="20">
29+
30+
<Button Style="{DynamicResource MainTitleButtonStyle}"
31+
Background="Transparent"
32+
BorderBrush="Transparent"
33+
Click="Leia_Link"
34+
HorizontalAlignment="Left"
35+
VerticalAlignment="Top"
36+
Margin="0,0,0,0" Height="44" Width="149" >
37+
</Button>
38+
39+
<Button
40+
Style="{DynamicResource TabCloseButtonStyle}"
41+
Name="CloseButton"
42+
Click="CancelProcess_Click"
43+
HorizontalAlignment="Right"
44+
VerticalAlignment="Top"/>
45+
46+
<StackPanel Orientation="Vertical" Margin="0,49,0,0">
47+
<Line Stroke="{DynamicResource MainGray}"
48+
X2="1000"
49+
Opacity="0.5"
50+
StrokeThickness="4"
51+
VerticalAlignment="Top"
52+
Margin="-9,0,-9,10" RenderTransformOrigin="0.5,0.5" Height="2">
53+
<Line.RenderTransform>
54+
<TransformGroup>
55+
<ScaleTransform ScaleY="1"/>
56+
<SkewTransform/>
57+
<RotateTransform/>
58+
<TranslateTransform/>
59+
</TransformGroup>
60+
</Line.RenderTransform>
61+
</Line>
62+
63+
<TextBlock TextWrapping="Wrap"
64+
Text="Email"
65+
TextAlignment="Left"
66+
Foreground="{DynamicResource MainGray}"
67+
HorizontalAlignment="Left"
68+
Height="18"
69+
VerticalAlignment="Top"
70+
RenderTransformOrigin="0.16,0.487"/>
71+
72+
<TextBox x:Name="email_textBox"
73+
Style="{DynamicResource MainTextBox}"
74+
TextWrapping="Wrap"
75+
Width="287"
76+
HorizontalAlignment="Center"
77+
Margin="0,5,0,20"/>
78+
79+
<TextBlock TextWrapping="Wrap"
80+
Text="Error Description"
81+
TextAlignment="Left"
82+
Foreground="{DynamicResource MainGray}"
83+
Height="18" />
84+
85+
<TextBox x:Name="description_textBox"
86+
Style="{DynamicResource MainTextBox}"
87+
TextWrapping="Wrap"
88+
VerticalAlignment="Top"
89+
Width="287"
90+
Height="50"
91+
Margin="0,5,0,20"/>
92+
93+
</StackPanel>
94+
95+
<Button Content="Report"
96+
Style="{DynamicResource MainButtonStyle}"
97+
Width="129"
98+
Click="Report_Click"
99+
HorizontalAlignment="Center"
100+
VerticalAlignment="Bottom"/>
101+
</Grid>
102+
</Border>
103+
104+
<Window.Resources>
105+
<ResourceDictionary>
106+
<ResourceDictionary.MergedDictionaries>
107+
<ResourceDictionary Source="Resources.xaml" />
108+
</ResourceDictionary.MergedDictionaries>
109+
</ResourceDictionary>
110+
</Window.Resources>
111+
112+
</Window>

0 commit comments

Comments
 (0)