Solución error guardado CSV

version 3.2
Gerardo/ErrorGuardadoCSV
Gerardo 2023-03-29 23:41:00 +02:00
parent e834cdfb57
commit f6435a0de9
8 changed files with 42 additions and 20 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ArcGIS defaultAssembly="OliviaAddInPro.dll" defaultNamespace="OliviaAddInPro" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd"> <ArcGIS defaultAssembly="OliviaAddInPro.dll" defaultNamespace="OliviaAddInPro" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{10742570-cf59-42f2-bea2-2a38002a06ee}" version="3.1" desktopVersion="3.0.3.36057"> <AddInInfo id="{10742570-cf59-42f2-bea2-2a38002a06ee}" version="3.2" desktopVersion="3.0.3.36057">
<Name>OliviaAddInPro</Name> <Name>OliviaAddInPro</Name>
<Description>AddIn de Optimización de la Limpieza Viaria para ArcGIs Pro</Description> <Description>AddIn de Optimización de la Limpieza Viaria para ArcGIs Pro</Description>
<Image>Images\AddinDesktop32.png</Image> <Image>Images\AddinDesktop32.png</Image>
<Author>VSM</Author> <Author>VSM</Author>
<Company>VSM - Narvaling</Company> <Company>VSM - Narvaling</Company>
<Date>18/01/2023 12:00:00, 2023</Date> <Date>18/04/2023 12:00:00, 2023</Date>
<Subject>Framework</Subject> <Subject>Framework</Subject>
<!-- Note subject can be one or more of these topics: <!-- Note subject can be one or more of these topics:
Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration --> Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration -->

View File

@ -27,6 +27,7 @@ using ArcGIS.Core.CIM;
using System.Threading; using System.Threading;
using ArcGIS.Core.Data.Exceptions; using ArcGIS.Core.Data.Exceptions;
using Microsoft.Win32; using Microsoft.Win32;
using Microsoft.WindowsAPICodePack.Dialogs;
namespace OliviaAddInPro.Helper namespace OliviaAddInPro.Helper
{ {
@ -1443,11 +1444,14 @@ namespace OliviaAddInPro.Helper
if (!System.IO.Directory.Exists(outpath)) if (!System.IO.Directory.Exists(outpath))
System.IO.Directory.CreateDirectory(outpath); System.IO.Directory.CreateDirectory(outpath);
FeatureClass fc = null; FeatureClass fc = null;
bool debug = true;
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
//Prepara una where_clause con las entidades que cumplen el filtro //Prepara una where_clause con las entidades que cumplen el filtro
//Abre la featureclass //Abre la featureclass
try try
{ {
if (debug)
HelperGlobal.ponMsg("pathLayerIn " + pathLayerIn);
fc = GetFtClassSync(pathLayerIn); fc = GetFtClassSync(pathLayerIn);
if (fc == null) if (fc == null)
{ {
@ -1456,14 +1460,17 @@ namespace OliviaAddInPro.Helper
} }
List<long> ids = new List<long>(); List<long> ids = new List<long>();
if (debug)
HelperGlobal.ponMsg("fc " + fc.GetName() + " tipo " + fc.GetType().Name);
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
//Añade a la lista los ids que cumplen el filtro espacial //Añade a la lista los ids que cumplen el filtro espacial
try try
{ {
ids = fc.Select(filter, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList(); ids = fc.Select(filter, SelectionType.ObjectID, SelectionOption.Normal).GetObjectIDs().ToList();
} }
catch catch(Exception ex)
{ {
OutStr = "Error al seleccionar IDs. "+ex.Message;
ids = new List<long>(); ids = new List<long>();
} }
@ -1479,7 +1486,7 @@ namespace OliviaAddInPro.Helper
}*/ }*/
if (ids.Count <= 0) if (ids.Count <= 0)
{ {
OutStr = "Error al aplicar filtro espacial en exportación"; OutStr = "Error al aplicar filtro espacial en exportación: "+ OutStr;
return false; return false;
} }
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
@ -2133,6 +2140,17 @@ namespace OliviaAddInPro.Helper
*/ */
public static string FolderBrowseDlg(string title_, string initloc_) public static string FolderBrowseDlg(string title_, string initloc_)
{ {
var openFileDialog = new CommonOpenFileDialog();
//{ IsFolderPicker = true };
if(!String.IsNullOrEmpty(initloc_))
openFileDialog.InitialDirectory = initloc_;
openFileDialog.IsFolderPicker = true;
//openFileDialog.InitialDirectory = initloc_;
openFileDialog.Title = title_;
//openFileDialog.Filter = "Folders";
//if (openFileDialog.ShowDialog() == true)
if (openFileDialog.ShowDialog() == CommonFileDialogResult.Ok)
return openFileDialog.FileName;
return null; return null;
} }

View File

@ -47,6 +47,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.103" /> <PackageReference Include="DotNetProjects.Extended.Wpf.Toolkit" Version="5.0.103" />
<PackageReference Include="Microsoft.WindowsAPICodePack.Shell" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<Reference Include="ArcGIS.Desktop.Framework"> <Reference Include="ArcGIS.Desktop.Framework">
<HintPath>C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll</HintPath> <HintPath>C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll</HintPath>

View File

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("VSM - Narvaling")] [assembly: AssemblyCompany("VSM - Narvaling")]
[assembly: AssemblyProduct("OliviaAddInPro")] [assembly: AssemblyProduct("OliviaAddInPro")]
[assembly: AssemblyCopyright("Copyright © VSM 2022")] [assembly: AssemblyCopyright("Copyright © VSM 2023")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.0.0")] [assembly: AssemblyVersion("3.2.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")] [assembly: AssemblyFileVersion("3.2.0.0")]

View File

@ -832,7 +832,6 @@ namespace OliviaAddInPro.Services
string shapefile = System.IO.Path.GetFileNameWithoutExtension(path_shape); string shapefile = System.IO.Path.GetFileNameWithoutExtension(path_shape);
int ind = shapefile.IndexOf("_", 0); int ind = shapefile.IndexOf("_", 0);
string prefijo = shapefile.Substring(ind + 1, 1); string prefijo = shapefile.Substring(ind + 1, 1);
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
//decodifica el nombre del shapefile para asignarle el correspondiente nombre en la GDB a la que se importa el shape //decodifica el nombre del shapefile para asignarle el correspondiente nombre en la GDB a la que se importa el shape
string tratamiento = string.Empty; string tratamiento = string.Empty;

View File

@ -54,7 +54,7 @@ namespace OliviaAddInPro.Services
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<bool>)(() => ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<bool>)(() =>
{ {
string GdbFileName = resp.Value; string GdbFileName = resp.Value;
string nombAmbitos = string.Empty;
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
{ {
//actualiza los flags //actualiza los flags
@ -130,7 +130,7 @@ namespace OliviaAddInPro.Services
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
{ {
//guarda csv //guarda csv
GuardaCsv(inst); GuardaCsv(inst,resp2.Value);
} }
msg = Resource1.String_exito; msg = Resource1.String_exito;
@ -209,7 +209,7 @@ namespace OliviaAddInPro.Services
/* /*
* Permite guardar el archivo CSV que contiene la secuencia que se ha llevado a cabo en las rutas en la planificación. * Permite guardar el archivo CSV que contiene la secuencia que se ha llevado a cabo en las rutas en la planificación.
*/ */
public static void GuardaCsv(TratamientoComun inst) public static void GuardaCsv(TratamientoComun inst, string pathImport)
{ {
string auxi, nombre = null; string auxi, nombre = null;
string[] nameDokL; string[] nameDokL;
@ -221,20 +221,23 @@ namespace OliviaAddInPro.Services
string Filter = "Secuencia en formato CSV (*.csv)|*.csv"; string Filter = "Secuencia en formato CSV (*.csv)|*.csv";
inst.decode_gdb(System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData), inst.decode_gdb(System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData),
out auxi, out nombre); out auxi, out nombre);
if (!string.IsNullOrEmpty(pathImport))
{
nombre = System.IO.Path.GetFileNameWithoutExtension(pathImport);
}
//string Path = HelperGdb.SaveFileDlg(Title, DirData, inst.ServCom.EXT_CSV, Filter); //string Path = HelperGdb.SaveFileDlg(Title, DirData, inst.ServCom.EXT_CSV, Filter);
string Path = string.Empty; string Path = string.Empty;
if (OliviaGlob.CompruebaExistePath(OliviaGlob.Paths.PathGuardCsv)) if (OliviaGlob.CompruebaExistePath(OliviaGlob.Paths.PathGuardCsv))
Path = OliviaGlob.Paths.PathGuardCsv; Path = OliviaGlob.Paths.PathGuardCsv;
else else
Path = HelperGdb.SaveFileDlg(Title, DirData, null, ArcGIS.Desktop.Catalog.ItemFilters.Folders); //Path = HelperGdb.SaveFileDlg(Title, DirData, null, ArcGIS.Desktop.Catalog.ItemFilters.Folders);
Path = HelperGdb.FolderBrowseDlg(Title, DirData);
if (string.IsNullOrEmpty(Path) || Path.Length == 0) if (string.IsNullOrEmpty(Path) || Path.Length == 0)
{ {
bool ok = HelperGlobal.ponMsg("Se va a perder el archivo que contiene la secuencia en planificación, ¿está seguro?", bool ok = HelperGlobal.ponMsg("Se va a perder el archivo que contiene la secuencia en planificación, ¿está seguro?",
MessageBoxImage.Question,"OLIVIA",MessageBoxButton.YesNo); MessageBoxImage.Question,"OLIVIA",MessageBoxButton.YesNo);
if (!ok) if (!ok)
GuardaCsv(inst); GuardaCsv(inst, pathImport);
} }
else else
{ {

View File

@ -53,7 +53,8 @@ namespace OliviaAddInPro.View.Configuracion
private void PickFileButton_Click(object sender, RoutedEventArgs e) private void PickFileButton_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog fd = new OpenFileDialog(); OpenFileDialog fd = new OpenFileDialog();
var st = HelperGdb.SaveFileDlg("Seleccione carpeta", null, null, ArcGIS.Desktop.Catalog.ItemFilters.Folders); //var st = HelperGdb.SaveFileDlg("Seleccione carpeta", null, null, ArcGIS.Desktop.Catalog.ItemFilters.Folders);
var st = HelperGdb.FolderBrowseDlg("Seleccione carpeta", null);
if (!string.IsNullOrEmpty(st)) if (!string.IsNullOrEmpty(st))
{ {
Value = st; Value = st;

View File

@ -49,7 +49,7 @@
</DataTemplate> </DataTemplate>
</--> </-->
</ComboBox> </ComboBox>
<TextBox x:Name="txtBox_densCont" Width="60" ToolTip="{Binding ToolTip_TextDensCont}" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" Visibility="{Binding Path=VisTextDens, Mode = TwoWay}" Grid.Column="1" Margin="10,0" TextWrapping="NoWrap" Text="{Binding Path=TextDensCont, Mode = TwoWay}" TextAlignment="Right" MaxLength="5" PreviewTextInput="txtBox_densCont_PreviewTextInput"/> <TextBox x:Name="txtBox_densCont" Width="60" ToolTip="{Binding ToolTip_TextDensCont}" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" Visibility="{Binding Path=VisTextDens, Mode = TwoWay}" Grid.Column="1" Margin="10,0" TextWrapping="NoWrap" Text="{Binding Path=TextDensCont, Mode = TwoWay}" TextAlignment="Right" MaxLength="8" PreviewTextInput="txtBox_densCont_PreviewTextInput"/>
<Label x:Name="label_densCont" Grid.Column="2" Content="kg/m3" Margin="0,-1,0,0" Visibility="{Binding Path=VisTextDens, Mode = TwoWay}"/> <Label x:Name="label_densCont" Grid.Column="2" Content="kg/m3" Margin="0,-1,0,0" Visibility="{Binding Path=VisTextDens, Mode = TwoWay}"/>
</Grid> </Grid>
<Label Content="Tipo de carga" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.391,-0.203" FontWeight="DemiBold"/> <Label Content="Tipo de carga" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.391,-0.203" FontWeight="DemiBold"/>
@ -91,7 +91,7 @@
<ComboBox x:Name="comboBox_tipoCapac" IsEnabled="{Binding EnabComboCapac, Mode=TwoWay}" ItemsSource="{Binding TiposCapac, Mode=TwoWay}" HorizontalAlignment="Left" Margin="0,0,0,0" <ComboBox x:Name="comboBox_tipoCapac" IsEnabled="{Binding EnabComboCapac, Mode=TwoWay}" ItemsSource="{Binding TiposCapac, Mode=TwoWay}" HorizontalAlignment="Left" Margin="0,0,0,0"
VerticalAlignment="Top" Width="75" VerticalAlignment="Top" Width="75"
SelectedIndex="{Binding TipoCapac}" SelectionChanged="comboBox_tipoCapac_SelectionChanged"/> SelectedIndex="{Binding TipoCapac}" SelectionChanged="comboBox_tipoCapac_SelectionChanged"/>
<TextBox x:Name="txtBox_kgCapac" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" Grid.Column="1" Margin="5,0,0,3" TextWrapping="NoWrap" Text="{Binding Path=TextKgCapac, Mode = TwoWay}" TextAlignment="Right" MaxLength="4" PreviewTextInput="txtBox_kgCapac_PreviewTextInput"/> <TextBox x:Name="txtBox_kgCapac" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" Grid.Column="1" Margin="5,0,0,3" TextWrapping="NoWrap" Text="{Binding Path=TextKgCapac, Mode = TwoWay}" TextAlignment="Right" MaxLength="8" PreviewTextInput="txtBox_kgCapac_PreviewTextInput"/>
<Label x:Name="label_kgmax" Grid.Column="2" Content="kg máx. por viaje" Margin="0,-1,0,0"/> <Label x:Name="label_kgmax" Grid.Column="2" Content="kg máx. por viaje" Margin="0,-1,0,0"/>
</Grid> </Grid>
<Label Content="Tiempo de vaciado de contenedor" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.391,-0.203" FontWeight="DemiBold"/> <Label Content="Tiempo de vaciado de contenedor" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.391,-0.203" FontWeight="DemiBold"/>
@ -100,7 +100,7 @@
<ColumnDefinition Width="80"/> <ColumnDefinition Width="80"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBox IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" Margin="0,0,0,8" TextWrapping="NoWrap" Text="{Binding Path=TextTVaci, Mode = TwoWay}" TextAlignment="Right" MaxLength="3" PreviewTextInput="TextBox_PreviewTextInput"/> <TextBox IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" Margin="0,0,0,8" TextWrapping="NoWrap" Text="{Binding Path=TextTVaci, Mode = TwoWay}" TextAlignment="Right" MaxLength="4" PreviewTextInput="TextBox_PreviewTextInput"/>
<Label Grid.Column="1" Content="seg." Margin="0,-3,0,8"/> <Label Grid.Column="1" Content="seg." Margin="0,-3,0,8"/>
</Grid> </Grid>
<Label Margin="15,0,0,0" Content="Planta de descarga" FontWeight="DemiBold"/> <Label Margin="15,0,0,0" Content="Planta de descarga" FontWeight="DemiBold"/>