Avances importación
parent
7f824052a3
commit
7ab639b800
|
|
@ -29,7 +29,8 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
private static string ObjectId = "OBJECTID";
|
||||
private static string out_str = string.Empty;
|
||||
public static string OutStr {
|
||||
public static string OutStr
|
||||
{
|
||||
get
|
||||
{
|
||||
/*string val = "";
|
||||
|
|
@ -43,7 +44,8 @@ namespace OliviaAddInPro.Helper
|
|||
private static string texto_sal = string.Empty;
|
||||
public static string TextoSal
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
/*string val = "";
|
||||
val.CopyFrom(texto_sal);
|
||||
texto_sal = string.Empty; //lo borra cada vez que se consulta
|
||||
|
|
@ -58,10 +60,10 @@ namespace OliviaAddInPro.Helper
|
|||
[Flags]
|
||||
public enum TiposOpenFileDlg
|
||||
{
|
||||
OpenFtrClassLine=1,
|
||||
OpenFtrClassPoint=2,
|
||||
OpenFtrClassPolygon=4,
|
||||
OpenGdb=8,
|
||||
OpenFtrClassLine = 1,
|
||||
OpenFtrClassPoint = 2,
|
||||
OpenFtrClassPolygon = 4,
|
||||
OpenGdb = 8,
|
||||
}
|
||||
|
||||
private static void ReiniciaOutStr()
|
||||
|
|
@ -112,8 +114,8 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
/**
|
||||
* Devuelve el sistema de coordenadas de una capa
|
||||
*/
|
||||
public static int GetCoorSys(string ftclasspath)
|
||||
*/
|
||||
public static int GetCoorSys(string ftclasspath)
|
||||
{
|
||||
FeatureClass fc = GetFtClass(ftclasspath);
|
||||
if (fc == null)
|
||||
|
|
@ -129,23 +131,23 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
FeatureClass fc = null;
|
||||
ReiniciaOutStr();
|
||||
string path = OpenFileDialog( tipo, initialLoc);
|
||||
if(!string.IsNullOrEmpty(path))
|
||||
string path = OpenFileDialog(tipo, initialLoc);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
fc = GetFtClass(path);
|
||||
}
|
||||
return fc;
|
||||
}
|
||||
}
|
||||
|
||||
//Libera el objeto
|
||||
public static void Free(IDisposable obj)
|
||||
{
|
||||
if(obj!=null)
|
||||
if (obj != null)
|
||||
obj.Dispose();
|
||||
}
|
||||
|
||||
//Devuelve el Path del archivo seleccionado o un string vacío si se ha cancelado
|
||||
public static string OpenFileDialog(TiposOpenFileDlg tipo, string initialLoc="")
|
||||
public static string OpenFileDialog(TiposOpenFileDlg tipo, string initialLoc = "", string tit_ = "")
|
||||
{
|
||||
string titulo;
|
||||
ReiniciaOutStr();
|
||||
|
|
@ -155,9 +157,9 @@ namespace OliviaAddInPro.Helper
|
|||
//fuentes filtros
|
||||
//https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Exploration/IdentifyWindow/Daml.cs
|
||||
BrowseProjectFilter filtro = new BrowseProjectFilter();
|
||||
if ((tipo & TiposOpenFileDlg.OpenFtrClassLine)== TiposOpenFileDlg.OpenFtrClassLine)
|
||||
if ((tipo & TiposOpenFileDlg.OpenFtrClassLine) == TiposOpenFileDlg.OpenFtrClassLine)
|
||||
{
|
||||
filtro.AddFilter(BrowseProjectFilter.GetFilter("esri_browseDialogFilters_featureClasses_line"));
|
||||
filtro.AddFilter(BrowseProjectFilter.GetFilter("esri_browseDialogFilters_featureClasses_line"));
|
||||
titulo = "Abrir Feature Class";
|
||||
}
|
||||
if ((tipo & TiposOpenFileDlg.OpenFtrClassPoint) == TiposOpenFileDlg.OpenFtrClassPoint)
|
||||
|
|
@ -175,19 +177,24 @@ namespace OliviaAddInPro.Helper
|
|||
filtro.AddFilter(BrowseProjectFilter.GetFilter("esri_browseDialogFilters_geodatabases"));
|
||||
titulo = "Abrir Geodatabase";
|
||||
}
|
||||
if(tipo==0)
|
||||
if (tipo == 0)
|
||||
{
|
||||
filtro.AddFilter(BrowseProjectFilter.GetFilter(""));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(tit_))
|
||||
titulo = tit_;
|
||||
|
||||
//Display the filter in an Open Item dialog
|
||||
OpenItemDialog aNewFilter = new OpenItemDialog
|
||||
{
|
||||
Title = titulo,
|
||||
InitialLocation = initialLoc,
|
||||
MultiSelect = false,
|
||||
//Set the BrowseFilter property to Pro's Geodatabase filter.
|
||||
BrowseFilter = filtro
|
||||
};
|
||||
if (!string.IsNullOrEmpty(initialLoc))
|
||||
aNewFilter.InitialLocation = initialLoc;
|
||||
|
||||
bool? ok = aNewFilter.ShowDialog();
|
||||
if ((ok ?? true) && aNewFilter.Items.Count() > 0)
|
||||
return aNewFilter.Items.First().Path;
|
||||
|
|
@ -203,10 +210,10 @@ namespace OliviaAddInPro.Helper
|
|||
return string.Empty;
|
||||
string pathGdb = string.Empty;
|
||||
int i = 0;
|
||||
if(path.Contains(GDB_EXT))
|
||||
if (path.Contains(GDB_EXT))
|
||||
{
|
||||
i = path.IndexOf(GDB_EXT, 0, path.Length);
|
||||
pathGdb = path.Substring(0,i + 4);
|
||||
pathGdb = path.Substring(0, i + 4);
|
||||
}
|
||||
|
||||
return pathGdb;
|
||||
|
|
@ -221,7 +228,7 @@ namespace OliviaAddInPro.Helper
|
|||
return null;
|
||||
ReiniciaOutStr();
|
||||
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<Geodatabase>)(() =>
|
||||
{
|
||||
{
|
||||
string path = GetPathGdb(pathGdb);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
|
|
@ -260,7 +267,7 @@ namespace OliviaAddInPro.Helper
|
|||
Free(gdb);
|
||||
return ftclss;
|
||||
}
|
||||
|
||||
|
||||
//Dado el path de una gdb y el nombre de una feature class, devuelve la
|
||||
//feature class abierta, o null si hay algun problema
|
||||
public static Task<FeatureClass> GetFtClass(string nameFtclss, Geodatabase gdb)
|
||||
|
|
@ -296,7 +303,7 @@ namespace OliviaAddInPro.Helper
|
|||
try
|
||||
{
|
||||
string shpname = System.IO.Path.GetFileNameWithoutExtension(pathShp);
|
||||
var shapeFileConnPath = new FileSystemConnectionPath(new Uri(System.IO.Path.GetDirectoryName(pathShp)),
|
||||
var shapeFileConnPath = new FileSystemConnectionPath(new Uri(System.IO.Path.GetDirectoryName(pathShp)),
|
||||
FileSystemDatastoreType.Shapefile);
|
||||
var shapefile = new FileSystemDatastore(shapeFileConnPath);
|
||||
ftclss = shapefile.OpenDataset<FeatureClass>(shpname);
|
||||
|
|
@ -316,7 +323,7 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
FeatureClassDefinition ftcldef = ftClss.GetDefinition();
|
||||
ReiniciaOutStr();
|
||||
ArcGIS.Core.Data.Field field=null;
|
||||
ArcGIS.Core.Data.Field field = null;
|
||||
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<ArcGIS.Core.Data.Field>)(() =>
|
||||
{
|
||||
try
|
||||
|
|
@ -330,13 +337,13 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
return field;
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Crea un filtro espacial a partir de una consulta y en todo caso, una geometría
|
||||
public static ArcGIS.Core.Data.SpatialQueryFilter CreateFiler(string consulta, ArcGIS.Core.Geometry.Geometry geom, SpatialRelationship rel= SpatialRelationship.Contains)
|
||||
public static ArcGIS.Core.Data.SpatialQueryFilter CreateFiler(string consulta, ArcGIS.Core.Geometry.Geometry geom, SpatialRelationship rel = SpatialRelationship.Contains)
|
||||
{
|
||||
ArcGIS.Core.Data.SpatialQueryFilter filt =null;
|
||||
ArcGIS.Core.Data.SpatialQueryFilter filt = null;
|
||||
if (geom != null)
|
||||
{
|
||||
SpatialQueryFilter filtSpat = new SpatialQueryFilter
|
||||
|
|
@ -361,7 +368,7 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
ReiniciaOutStr();
|
||||
List<long> ids = new List<long>();
|
||||
Selection sel=null;
|
||||
Selection sel = null;
|
||||
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<List<long>>)(() =>
|
||||
{
|
||||
if (fc == null)
|
||||
|
|
@ -372,7 +379,7 @@ namespace OliviaAddInPro.Helper
|
|||
filt = new ArcGIS.Core.Data.QueryFilter();
|
||||
sel = fc.Select(filt, SelectionType.ObjectID, SelectionOption.Normal);
|
||||
int nsel = sel.GetCount();
|
||||
IReadOnlyList<long> ids_= sel.GetObjectIDs();
|
||||
IReadOnlyList<long> ids_ = sel.GetObjectIDs();
|
||||
ids = ids_.ToList();
|
||||
return ids;
|
||||
}
|
||||
|
|
@ -391,8 +398,8 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
//Devuelve una lista con los campos de una feature class
|
||||
public static Task<ObservableCollection<string>> GetFields(FeatureClass fc)
|
||||
{
|
||||
FeatureClassDefinition ftcldef=null;
|
||||
{
|
||||
FeatureClassDefinition ftcldef = null;
|
||||
IReadOnlyList<ArcGIS.Core.Data.Field> fields = null;
|
||||
ReiniciaOutStr();
|
||||
ObservableCollection<string> fields_st = new ObservableCollection<string>();
|
||||
|
|
@ -422,7 +429,7 @@ namespace OliviaAddInPro.Helper
|
|||
* Comprueba que en la capa dada exista un campo con nombre 'field'
|
||||
*/
|
||||
public static bool CheckField(string pathCapa, string field)
|
||||
{
|
||||
{
|
||||
FeatureClass fc = GetFtClass(pathCapa);
|
||||
if (fc == null)
|
||||
{
|
||||
|
|
@ -500,8 +507,8 @@ namespace OliviaAddInPro.Helper
|
|||
return GetFieldVals(fc, fieldName, uniquevals);
|
||||
}
|
||||
|
||||
//Dado un nombre de campo, devuelve los valores que encuentra para ese nombre de campo
|
||||
public static Task<ObservableCollection<string>> GetFieldVals(FeatureClass fc, string fieldName, bool uniquevals)
|
||||
//Dado un nombre de campo, devuelve los valores que encuentra para ese nombre de campo
|
||||
public static Task<ObservableCollection<string>> GetFieldVals(FeatureClass fc, string fieldName, bool uniquevals)
|
||||
{
|
||||
ObservableCollection<string> attribs_st = new ObservableCollection<string>();
|
||||
ReiniciaOutStr();
|
||||
|
|
@ -544,7 +551,7 @@ namespace OliviaAddInPro.Helper
|
|||
* Devuelve una geometría que es la suma de la inicial y la que se añade Add
|
||||
*/
|
||||
public static ArcGIS.Core.Geometry.Geometry IntersectGeom(ArcGIS.Core.Geometry.Geometry geomIni, ArcGIS.Core.Geometry.Geometry geomInters,
|
||||
GeometryDimension resultDimension= GeometryDimension.esriGeometryNoDimension)
|
||||
GeometryDimension resultDimension = GeometryDimension.esriGeometryNoDimension)
|
||||
{
|
||||
if (geomIni == null)
|
||||
return geomInters;
|
||||
|
|
@ -553,8 +560,8 @@ namespace OliviaAddInPro.Helper
|
|||
ArcGIS.Core.Geometry.Geometry geomSal = null;
|
||||
try
|
||||
{
|
||||
if(resultDimension== GeometryDimension.esriGeometryNoDimension)
|
||||
geomSal =GeometryEngine.Instance.Intersection(geomIni, geomInters);
|
||||
if (resultDimension == GeometryDimension.esriGeometryNoDimension)
|
||||
geomSal = GeometryEngine.Instance.Intersection(geomIni, geomInters);
|
||||
else
|
||||
geomSal = GeometryEngine.Instance.Intersection(geomIni, geomInters, resultDimension);
|
||||
|
||||
|
|
@ -579,7 +586,7 @@ namespace OliviaAddInPro.Helper
|
|||
try
|
||||
{
|
||||
geomSal = GeometryEngine.Instance.Union(geomIni, geomUne);
|
||||
|
||||
|
||||
return geomSal;
|
||||
}
|
||||
catch
|
||||
|
|
@ -620,7 +627,7 @@ namespace OliviaAddInPro.Helper
|
|||
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<ArcGIS.Core.Geometry.Geometry>)(() =>
|
||||
{
|
||||
geomIni = GetGeomUnique(fclss, filter);
|
||||
return geomIni;
|
||||
return geomIni;
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
@ -631,7 +638,7 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
ArcGIS.Core.Geometry.Geometry geomsal = null;
|
||||
ReiniciaOutStr();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var geom = new List<ArcGIS.Core.Geometry.Geometry>();
|
||||
|
|
@ -643,10 +650,10 @@ namespace OliviaAddInPro.Helper
|
|||
using (Row row = rowCursor.Current)
|
||||
{
|
||||
if (row is Feature ft)
|
||||
geom.Add(ft.GetShape());
|
||||
geom.Add(ft.GetShape());
|
||||
}
|
||||
}
|
||||
geomsal= GeometryEngine.Instance.Union(geom);
|
||||
geomsal = GeometryEngine.Instance.Union(geom);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -665,7 +672,7 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
ArcGIS.Core.Geometry.Geometry geomsal = null;
|
||||
ArcGIS.Core.Geometry.Geometry geomAux = null;
|
||||
string where = "";
|
||||
string where = "";
|
||||
ArcGIS.Core.Data.Field f;
|
||||
ArcGIS.Core.Data.QueryFilter filtro;
|
||||
bool ok = true;
|
||||
|
|
@ -685,7 +692,7 @@ namespace OliviaAddInPro.Helper
|
|||
where = $"{fieldName} = {Quote(f)}{selFieldVals[i]}{Quote(f)}";
|
||||
filtro = new ArcGIS.Core.Data.QueryFilter { WhereClause = where };
|
||||
geomAux = GetGeomUnique(fclss, filtro);
|
||||
if(geomAux == null)
|
||||
if (geomAux == null)
|
||||
{
|
||||
ok = false;
|
||||
continue;
|
||||
|
|
@ -698,7 +705,7 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HelperGdb.OutStr = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where +": " + ex.Message;
|
||||
HelperGdb.OutStr = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where + ": " + ex.Message;
|
||||
return geomsal;
|
||||
|
||||
}
|
||||
|
|
@ -718,8 +725,8 @@ namespace OliviaAddInPro.Helper
|
|||
if (gdb != null)
|
||||
{
|
||||
fc = GetFtClass(ftclssName, gdb).Result;
|
||||
if(fc!=null)
|
||||
n= GetNumElems(fc, consulta).Result;
|
||||
if (fc != null)
|
||||
n = GetNumElems(fc, consulta).Result;
|
||||
}
|
||||
Free(fc);
|
||||
Free(gdb);
|
||||
|
|
@ -729,7 +736,7 @@ namespace OliviaAddInPro.Helper
|
|||
/**
|
||||
* Devuelve los valores únicos de un campo dado
|
||||
*/
|
||||
public static ObservableCollection<string> GetUniqueVals(string capa, string campo)
|
||||
public static ObservableCollection<string> GetUniqueVals(string capa, string campo)
|
||||
{
|
||||
ObservableCollection<string> uniqueVals = null;
|
||||
FeatureClass ftclass = GetFtClass(capa);
|
||||
|
|
@ -742,11 +749,11 @@ namespace OliviaAddInPro.Helper
|
|||
ArcGIS.Core.Data.Field fld = featureClassDefinition.GetFields().First(x => x.Name.Equals(campo));
|
||||
|
||||
// Create StatisticsDescriptions
|
||||
StatisticsDescription uniqStatDesc = new StatisticsDescription(fld, new List<ArcGIS.Core.Data.StatisticsFunction>()
|
||||
StatisticsDescription uniqStatDesc = new StatisticsDescription(fld, new List<ArcGIS.Core.Data.StatisticsFunction>()
|
||||
{ ArcGIS.Core.Data.StatisticsFunction.Count });
|
||||
|
||||
|
||||
// Create TableStatisticsDescription
|
||||
TableStatisticsDescription tableStatisticsDescription = new TableStatisticsDescription(new List<StatisticsDescription>() { uniqStatDesc});
|
||||
TableStatisticsDescription tableStatisticsDescription = new TableStatisticsDescription(new List<StatisticsDescription>() { uniqStatDesc });
|
||||
tableStatisticsDescription.GroupBy = new List<ArcGIS.Core.Data.Field>() { fld };
|
||||
tableStatisticsDescription.OrderBy = new List<SortDescription>() { new SortDescription(fld) };
|
||||
|
||||
|
|
@ -756,7 +763,7 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
// Code to process results goes here...
|
||||
uniqueVals = new ObservableCollection<string>();
|
||||
for(int i=0; i< statRes.StatisticsResults.Count; i++)
|
||||
for (int i = 0; i < statRes.StatisticsResults.Count; i++)
|
||||
{
|
||||
uniqueVals.Add(statRes.StatisticsResults.ElementAt(i).ToString());
|
||||
}
|
||||
|
|
@ -804,7 +811,7 @@ namespace OliviaAddInPro.Helper
|
|||
public static int GetNumElems(string pathFtClss, string consulta = "")
|
||||
{
|
||||
FeatureClass fc = GetFtClass(pathFtClss);
|
||||
int n=GetNumElems(fc,consulta).Result;
|
||||
int n = GetNumElems(fc, consulta).Result;
|
||||
Free(fc);
|
||||
return n;
|
||||
}
|
||||
|
|
@ -815,13 +822,13 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
string name = System.IO.Path.GetFileName(path);
|
||||
if (!string.IsNullOrEmpty(old_ext))
|
||||
name.Replace(old_ext,"");
|
||||
string _ex =System.IO.Path.GetExtension(nameNew);
|
||||
name.Replace(old_ext, "");
|
||||
string _ex = System.IO.Path.GetExtension(nameNew);
|
||||
string nn = nameNew;
|
||||
if (!string.IsNullOrEmpty(_ex))
|
||||
nn=nn.Replace(_ex, "");
|
||||
var res = true;
|
||||
foreach(var ex in extensions)
|
||||
nn = nn.Replace(_ex, "");
|
||||
var res = true;
|
||||
foreach (var ex in extensions)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -830,9 +837,9 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
if (!File.Exists(po))
|
||||
res = false;//no existe
|
||||
if (File.Exists(pn))
|
||||
if (File.Exists(pn))
|
||||
File.Delete(pn);
|
||||
File.Move(po,pn );
|
||||
File.Move(po, pn);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -843,7 +850,7 @@ namespace OliviaAddInPro.Helper
|
|||
return res;
|
||||
}
|
||||
|
||||
public static bool ExportShp2(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, IprocessManager cps, ArcGIS.Core.Geometry.SpatialReference sr=null, int incmax=100 )
|
||||
public static bool ExportShp2(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, IprocessManager cps, ArcGIS.Core.Geometry.SpatialReference sr = null, int incmax = 100)
|
||||
{
|
||||
if (!System.IO.Directory.Exists(outpath))
|
||||
System.IO.Directory.CreateDirectory(outpath);
|
||||
|
|
@ -860,7 +867,7 @@ namespace OliviaAddInPro.Helper
|
|||
return false;
|
||||
}
|
||||
List<long> ids = new List<long>();
|
||||
|
||||
|
||||
//Añade a la lista los ids que cumplen el filtro espacial
|
||||
using (RowCursor cursor = fc.Search(filter))
|
||||
{
|
||||
|
|
@ -885,9 +892,9 @@ namespace OliviaAddInPro.Helper
|
|||
///Exporta
|
||||
string[] args = { pathLayerIn, outpath, nameShp, whereClause };
|
||||
// execute the tool
|
||||
if(sr==null)
|
||||
if (sr == null)
|
||||
{
|
||||
sr= fc.GetDefinition().GetSpatialReference();
|
||||
sr = fc.GetDefinition().GetSpatialReference();
|
||||
}
|
||||
var environments = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: sr);
|
||||
//SpatialReferenceBuilder.CreateSpatialReference(3857)
|
||||
|
|
@ -907,7 +914,7 @@ namespace OliviaAddInPro.Helper
|
|||
case "OnProgressMessage":
|
||||
{
|
||||
string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
|
||||
Debug.WriteLine(msg); ;
|
||||
Debug.WriteLine(msg); ;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -915,11 +922,11 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
|
||||
Debug.WriteLine(msg2);
|
||||
var av = (int)o;
|
||||
var av = (int)o;
|
||||
if (av > 0)
|
||||
{
|
||||
cps.SetProgress(valini + (Math.Min((double)av/100.0, 100.0)*Math.Min(incmax, 100-valini)));
|
||||
}
|
||||
cps.SetProgress(valini + (Math.Min((double)av / 100.0, 100.0) * Math.Min(incmax, 100 - valini)));
|
||||
}
|
||||
// if ((int)o < 0)
|
||||
//System.Windows.MessageBox.Show(msg2);
|
||||
//_cts.Cancel();
|
||||
|
|
@ -933,7 +940,7 @@ namespace OliviaAddInPro.Helper
|
|||
cps.Setcancelled();
|
||||
return false;
|
||||
}
|
||||
if(gpResult.IsFailed)
|
||||
if (gpResult.IsFailed)
|
||||
{
|
||||
string msg;
|
||||
if (gpResult.ErrorMessages != null)
|
||||
|
|
@ -957,12 +964,12 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
}
|
||||
|
||||
public static bool ExportShp(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, CancelableProgressorSource cps, out string msgOut, ProgressorSource progrDialog = null)
|
||||
public static bool ExportShp(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, CancelableProgressorSource cps, out string msgOut, ProgressorSource progrDialog = null)
|
||||
{
|
||||
msgOut = "";
|
||||
if (!System.IO.Directory.Exists(outpath))
|
||||
System.IO.Directory.CreateDirectory(outpath);
|
||||
|
||||
|
||||
|
||||
//fc.
|
||||
/*
|
||||
|
|
@ -1026,7 +1033,7 @@ namespace OliviaAddInPro.Helper
|
|||
|
||||
*/
|
||||
cps.Status = "Guardando geometria a shp";
|
||||
|
||||
|
||||
string[] args = { pathLayerIn, outpath };
|
||||
// execute the tool
|
||||
IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToShapefile_conversion", args,
|
||||
|
|
@ -1037,8 +1044,8 @@ namespace OliviaAddInPro.Helper
|
|||
switch (event_name)
|
||||
{
|
||||
case "OnValidate": // stop execute if any warnings
|
||||
//if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
|
||||
//_cts.Cancel();
|
||||
//if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
|
||||
//_cts.Cancel();
|
||||
break;
|
||||
|
||||
case "OnProgressMessage":
|
||||
|
|
@ -1046,8 +1053,8 @@ namespace OliviaAddInPro.Helper
|
|||
string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
|
||||
//progrDialog.Message = (string)o;
|
||||
Debug.WriteLine(msg);
|
||||
|
||||
;
|
||||
|
||||
;
|
||||
//System.Windows.MessageBox.Show(msg);
|
||||
//_cts.Cancel();
|
||||
}
|
||||
|
|
@ -1092,9 +1099,9 @@ namespace OliviaAddInPro.Helper
|
|||
/**
|
||||
* Comprueba si un punto está contenido en un polígono
|
||||
*/
|
||||
public static Respuesta<bool> IsPtoInGeom(Coordinate2D pto, ArcGIS.Core.Geometry.Geometry geom)
|
||||
public static Respuesta<bool> IsPtoInGeom(Coordinate2D pto, ArcGIS.Core.Geometry.Geometry geom)
|
||||
{
|
||||
Respuesta<bool> resp=new Respuesta<bool>();
|
||||
Respuesta<bool> resp = new Respuesta<bool>();
|
||||
try
|
||||
{
|
||||
ArcGIS.Core.Geometry.Geometry geom_convexhull = GeometryEngine.Instance.ConvexHull(geom);
|
||||
|
|
@ -1104,7 +1111,7 @@ namespace OliviaAddInPro.Helper
|
|||
return resp;
|
||||
}
|
||||
catch
|
||||
{
|
||||
{
|
||||
resp.Value = false;
|
||||
resp.Error.Add("Error al comprobar si punto está contenido en polígono");
|
||||
return resp;
|
||||
|
|
@ -1113,7 +1120,7 @@ namespace OliviaAddInPro.Helper
|
|||
/**
|
||||
* Amplía la geometría para añadirele buffer
|
||||
*/
|
||||
public static Respuesta<ArcGIS.Core.Geometry.Geometry> BufferGeom(ArcGIS.Core.Geometry.Geometry geom, double buffer)
|
||||
public static Respuesta<ArcGIS.Core.Geometry.Geometry> BufferGeom(ArcGIS.Core.Geometry.Geometry geom, double buffer)
|
||||
{
|
||||
Respuesta<ArcGIS.Core.Geometry.Geometry> resp = new Respuesta<ArcGIS.Core.Geometry.Geometry>();
|
||||
ArcGIS.Core.Geometry.Geometry geomBuff = null;
|
||||
|
|
@ -1143,14 +1150,14 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
buffer += 100;
|
||||
geom_pto = GeometryEngine.Instance.Buffer(pto.ToMapPoint(), buffer);
|
||||
if(geom_pto==null || geom_pto.IsEmpty)
|
||||
if (geom_pto == null || geom_pto.IsEmpty)
|
||||
{
|
||||
resp.Value = null;
|
||||
resp.Error.Add("Error al bufferear punto para incluirlo en polígono");
|
||||
return resp;
|
||||
}
|
||||
//hace la convex hull, por si no fueran conexas las zonas
|
||||
repite= GeometryEngine.Instance.Disjoint(geom_pto, geom);
|
||||
repite = GeometryEngine.Instance.Disjoint(geom_pto, geom);
|
||||
/*if (geom_aux == null || geom_aux.IsEmpty)
|
||||
{
|
||||
ArcGIS.Core.Geometry.Envelope env1 = geom_sal.Extent;
|
||||
|
|
@ -1241,8 +1248,9 @@ namespace OliviaAddInPro.Helper
|
|||
string message = String.Empty;
|
||||
bool deletionResult = false;
|
||||
|
||||
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => {
|
||||
|
||||
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
|
||||
{
|
||||
|
||||
EditOperation editOperation = new EditOperation();
|
||||
editOperation.Callback(context =>
|
||||
{
|
||||
|
|
@ -1275,7 +1283,7 @@ namespace OliviaAddInPro.Helper
|
|||
{
|
||||
message = exObj.Message;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
|
|
@ -1364,7 +1372,7 @@ namespace OliviaAddInPro.Helper
|
|||
double longi_zon = 0, longi_tot = 0;
|
||||
List<long> quita = new List<long>();
|
||||
|
||||
int j=0;
|
||||
int j = 0;
|
||||
List<long> ids;
|
||||
try
|
||||
{
|
||||
|
|
@ -1372,14 +1380,14 @@ namespace OliviaAddInPro.Helper
|
|||
ids = GetIds(fc, null).Result;
|
||||
//Recorre las features de la capa
|
||||
RowCursor cursor = fc.Search();
|
||||
while(cursor.MoveNext())
|
||||
while (cursor.MoveNext())
|
||||
{
|
||||
f = (Feature)cursor.Current;
|
||||
geom = f.GetShape();
|
||||
line = (ArcGIS.Core.Geometry.Polyline)geom;
|
||||
longi_tot = line.Length;
|
||||
geom= IntersectGeom(geom_zon, line,GeometryDimension.esriGeometry1Dimension);
|
||||
line =(ArcGIS.Core.Geometry.Polyline)geom;
|
||||
geom = IntersectGeom(geom_zon, line, GeometryDimension.esriGeometry1Dimension);
|
||||
line = (ArcGIS.Core.Geometry.Polyline)geom;
|
||||
longi_zon = line.Length;//se consigue la longitud de ámbito (linea) que interseca con el nivel)
|
||||
if ((longi_zon / longi_tot) < porc)
|
||||
{
|
||||
|
|
@ -1393,7 +1401,7 @@ namespace OliviaAddInPro.Helper
|
|||
Free(cursor);
|
||||
|
||||
//comprueba que no se haya quedado sin ámbitos
|
||||
if (quita.Count>=fc.GetCount())
|
||||
if (quita.Count >= fc.GetCount())
|
||||
{
|
||||
OutStr = "No quedan ámbitos que cumplan la geometría seleccionada.";
|
||||
return false;
|
||||
|
|
@ -1418,12 +1426,12 @@ namespace OliviaAddInPro.Helper
|
|||
HelperGdb.Free(fc);
|
||||
HelperGdb.Free(f);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dado un nombre de capa mira si está abierta y la cierra
|
||||
*/
|
||||
*/
|
||||
public static bool CloseLayer(string nombCapa)
|
||||
{
|
||||
try
|
||||
|
|
@ -1440,5 +1448,30 @@ namespace OliviaAddInPro.Helper
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saca diálogo para guardar un archivo
|
||||
*/
|
||||
public static string SaveFileDlg(string title_, string initloc_, string ext_, string filt_)
|
||||
{
|
||||
//Display the filter in an Open Item dialog
|
||||
SaveItemDialog dlg = new SaveItemDialog
|
||||
{
|
||||
Title = title_,
|
||||
OverwritePrompt = true,
|
||||
};
|
||||
if (!string.IsNullOrEmpty(initloc_))
|
||||
dlg.InitialLocation = initloc_;
|
||||
if (!string.IsNullOrEmpty(filt_))
|
||||
dlg.Filter = filt_;
|
||||
if (!string.IsNullOrEmpty(ext_))
|
||||
dlg.DefaultExt = ext_;
|
||||
|
||||
bool? ok = dlg.ShowDialog();
|
||||
|
||||
if ((ok ?? true) && dlg.FilePath.Length > 0)
|
||||
return dlg.FilePath;
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,17 @@ namespace OliviaAddInPro.Model
|
|||
* Instancia para las funciones de exportación y demás
|
||||
*/
|
||||
|
||||
public LimpiezaServ Serv { get; set; } = null;
|
||||
public LimpiezaServ Serv
|
||||
{
|
||||
get
|
||||
{
|
||||
return (LimpiezaServ)ServCom;
|
||||
}
|
||||
set
|
||||
{
|
||||
ServCom = value;
|
||||
}
|
||||
}
|
||||
public LanzaLimpSrv LanzaSrv { get; set; } = null;
|
||||
|
||||
/**
|
||||
|
|
@ -46,9 +56,7 @@ namespace OliviaAddInPro.Model
|
|||
public Limpieza()
|
||||
{
|
||||
Serv = new LimpiezaServ(this);
|
||||
LanzaSrv = new LanzaLimpSrv();
|
||||
ProceSrv = new ProcesoEjecServ();
|
||||
ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
|
||||
LanzaSrv = new LanzaLimpSrv();
|
||||
}
|
||||
|
||||
public override Respuesta<TiposEjecucion> Ejecuta(ModosEjec modo)
|
||||
|
|
@ -73,5 +81,55 @@ namespace OliviaAddInPro.Model
|
|||
}
|
||||
return res2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Descodifica el nombre del sahpefile de entrada identificando el tipo de tratamiento y los ámbitos de trabajo
|
||||
*/
|
||||
public override void decode_gdb(string shapefile, out string tratamiento, out string ambitos)
|
||||
{
|
||||
int aux, auxl, mbito, indice, tratamient;
|
||||
string auxili, ambi, auxi;
|
||||
|
||||
indice = shapefile.IndexOf("_");
|
||||
indice = indice + 2;//para saltarse la T que va antes del identificador del tipo de tratamiento
|
||||
auxili = shapefile.Substring(indice, 2);
|
||||
tratamient = Convert.ToInt32(auxili);
|
||||
tratamiento = LimpiezaDef.tto_gdb[tratamient];
|
||||
indice = shapefile.IndexOf("_", indice);
|
||||
indice = indice + 2;//para saltarse la A que va antes del identificador de los ámbitos que intervienen
|
||||
aux = shapefile.IndexOf("_", indice);
|
||||
auxl = aux - indice;
|
||||
auxi = "";
|
||||
while (auxl > 0)
|
||||
{
|
||||
ambi = shapefile.Substring(indice, 2);
|
||||
mbito = Convert.ToInt32(ambi);
|
||||
indice = indice + 2;
|
||||
auxl = auxl - 2;
|
||||
if (auxl != 0)
|
||||
auxi = auxi + LimpiezaDef.ambs_gdb[mbito] + "_";
|
||||
else
|
||||
auxi = auxi + LimpiezaDef.ambs_gdb[mbito];
|
||||
}
|
||||
ambitos = LimpiezaDef.preftto_gdb[tratamient] + "_" + auxi;
|
||||
|
||||
//quita los espacios
|
||||
tratamiento = tratamiento.Replace(" ", "_");
|
||||
ambitos = ambitos.Replace(" ", "_");
|
||||
|
||||
auxi = shapefile;
|
||||
//para poner la zona cuando es seleccionada
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
indice = auxi.LastIndexOf("_");
|
||||
auxi = auxi.Substring(0, indice);
|
||||
}
|
||||
auxl = indice - aux;
|
||||
if (auxl <= 0)
|
||||
return;
|
||||
auxili = shapefile.Substring(aux, auxl);
|
||||
ambitos = ambitos + auxili;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ namespace OliviaAddInPro.Model
|
|||
get { return reco; }
|
||||
set { reco = value; }
|
||||
}
|
||||
public static EjecServ Serv { get; } = new EjecServ();
|
||||
public static SpatialReference SpatRef { get; set; } = null;
|
||||
public static MarchandoUnaDe progrDialog { get; set; } = null;
|
||||
#endregion Properties
|
||||
|
|
|
|||
|
|
@ -69,12 +69,22 @@ namespace OliviaAddInPro.Model
|
|||
get;
|
||||
set;
|
||||
}
|
||||
public RecogidaServ Serv { get; set; } = null;
|
||||
public RecogidaServ Serv
|
||||
{
|
||||
get
|
||||
{
|
||||
return (RecogidaServ)ServCom;
|
||||
}
|
||||
set
|
||||
{
|
||||
ServCom = value;
|
||||
}
|
||||
}
|
||||
public LanzaRecoSrv LanzaSrv { get; set; } = null;
|
||||
public Recogida()
|
||||
{
|
||||
Serv = new RecogidaServ(this);
|
||||
LanzaSrv = new LanzaRecoSrv();
|
||||
LanzaSrv = new LanzaRecoSrv();
|
||||
}
|
||||
|
||||
public override Respuesta<TiposEjecucion> Ejecuta(ModosEjec modo)
|
||||
|
|
@ -99,5 +109,48 @@ namespace OliviaAddInPro.Model
|
|||
}
|
||||
return res2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Descodifica el nombre del sahpefile de entrada identificando el tipo de fracción y la carga para la recogida de residuos
|
||||
*/
|
||||
public override void decode_gdb(string shapefile, out string fraccion, out string carga)
|
||||
{
|
||||
int aux, auxl, carg, indice, fracc;
|
||||
string auxili, fra, auxi;
|
||||
|
||||
indice = shapefile.IndexOf("_");
|
||||
indice = indice + 2;//para saltarse la F que va antes del identificador del tipo de fracción
|
||||
auxili = shapefile.Substring(indice, 2);
|
||||
fracc = Convert.ToInt32(auxili);
|
||||
fraccion = RecogidaDef.tipos_fracc_str[fracc];
|
||||
indice = shapefile.IndexOf("_", indice);
|
||||
indice = indice + 2;//para saltarse la C que va antes del identificador de los tipos de carga de los vehículos
|
||||
aux = shapefile.IndexOf("_", indice);
|
||||
|
||||
auxi = "";
|
||||
|
||||
fra = shapefile.Substring(indice, 2);
|
||||
carg = Convert.ToInt32(fra);
|
||||
|
||||
carga = RecogidaDef.tipos_fracc_str[fracc] + "_" + RecogidaDef.tipos_carg_str[carg];
|
||||
|
||||
//quita los espacios
|
||||
fraccion = fraccion.Replace(" ", "_");
|
||||
carga = carga.Replace(" ", "_");
|
||||
////////////////////////
|
||||
|
||||
auxi = shapefile;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
indice = auxi.LastIndexOf("_");
|
||||
auxi = auxi.Substring(0, indice);
|
||||
}
|
||||
auxl = indice - aux;
|
||||
if (auxl <= 0)
|
||||
return;
|
||||
auxili = shapefile.Substring(aux, auxl);
|
||||
carga = carga + auxili;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ namespace OliviaAddInPro.Model
|
|||
public MyCancelableProgressorSource ProgrSrc { get; set; } = null;
|
||||
public ProcesoEjecServ ProceSrv { get; set; } = null;
|
||||
public FinProcServ FinProceSrv { get; set; } = null;
|
||||
public EjecServ ServCom { get; set; } = null;
|
||||
|
||||
public TratamientoComun()
|
||||
{
|
||||
|
|
@ -151,15 +152,15 @@ namespace OliviaAddInPro.Model
|
|||
//oculta la ventana
|
||||
OliviaGlob.ShowHidePane(false);
|
||||
//comienza ejecución
|
||||
Action<Respuesta<TiposEjecucion>> ac = FinProceSrv.finEjecuta;
|
||||
Action<Respuesta<TiposEjecucion>, TratamientoComun> ac = FinProceSrv.finEjecuta;
|
||||
EjecutaAsync(modo, ac);
|
||||
}
|
||||
public async void EjecutaAsync(ModosEjec modo, Action<Respuesta<TiposEjecucion>> ffin)
|
||||
public async void EjecutaAsync(ModosEjec modo, Action<Respuesta<TiposEjecucion>, TratamientoComun> ffin)
|
||||
{
|
||||
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
|
||||
{
|
||||
var res = Ejecuta(modo);
|
||||
ffin(res);
|
||||
ffin(res, this);
|
||||
return res;
|
||||
});
|
||||
|
||||
|
|
@ -170,5 +171,14 @@ namespace OliviaAddInPro.Model
|
|||
res.Error.Add("No implementado");
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Descodifica el nombre del sahpefile de entrada identificando el tipo de tratamiento y los ámbitos de trabajo
|
||||
*/
|
||||
public virtual void decode_gdb(string shapefile, out string tratamiento, out string ambitos)
|
||||
{
|
||||
tratamiento = string.Empty;
|
||||
ambitos = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,15 +72,7 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
|
||||
//mira spatialreference de los datos de entrada
|
||||
spatRefData = geom_export.SpatialReference;
|
||||
//AQUÍ COMPARAR SI ES IGUAL QUE SPATREFDEF Y SI NO, REPROYECTAR
|
||||
/*if(spatRef.Wkid!=GeneralDef.SpatRefDef)
|
||||
{
|
||||
/*
|
||||
* FALTA HACER
|
||||
* dame_geom_coords en v2010
|
||||
*/
|
||||
//}
|
||||
spatRefData = geom_export.SpatialReference;
|
||||
|
||||
//crea el filtro de exportación
|
||||
filtroEspacial = HelperGdb.CreateFiler(com.ConsultaAmbs, geom_export);
|
||||
|
|
@ -204,8 +196,7 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
|
||||
//mira spatialreference del nw
|
||||
FeatureClass fc = HelperGdb.GetFtClass(OliviaGlob.Paths.PathGdbNw);
|
||||
/*
|
||||
/*FeatureClass fc = HelperGdb.GetFtClass(OliviaGlob.Paths.PathGdbNw);
|
||||
if (fc != null)
|
||||
{
|
||||
spatRef = fc.GetDefinition().GetSpatialReference();
|
||||
|
|
@ -367,6 +358,52 @@ namespace OliviaAddInPro.Services
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Realiza las funciones de importación de la sectorización
|
||||
*/
|
||||
public Respuesta<bool> ImportSecto(string GdbFileName)
|
||||
{
|
||||
var res = new Respuesta<bool> { Value = false };
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
//temp
|
||||
string name;
|
||||
res = import_secto_fin(GdbFileName, out name);
|
||||
if (!res.Value)
|
||||
{
|
||||
res.Error.Add("Error al importar resultados.");
|
||||
return res;
|
||||
}
|
||||
res = pinta_sectores(GdbFileName, name, 4);
|
||||
if (!res.Value)
|
||||
{
|
||||
res.Error.Add("Error al pintar sectores.");
|
||||
return res;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
res.Error.Add("Se ha cancelado la importación de resultados.");
|
||||
return res;
|
||||
}
|
||||
res.Value = true;
|
||||
return res;*/
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Realiza las funciones de importación de la planificación
|
||||
*/
|
||||
public Respuesta<bool> ImportPlanif(string GdbFileName)
|
||||
{
|
||||
var res = new Respuesta<bool> { Value = false };
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@ namespace OliviaAddInPro.Services
|
|||
{
|
||||
public class FinProcServ
|
||||
{
|
||||
public void finEjecuta(Respuesta<TiposEjecucion> res)
|
||||
public void finEjecuta(Respuesta<TiposEjecucion> res, TratamientoComun inst)
|
||||
{
|
||||
//REVISAR CUANDO ACABA, SE CAMBIE EL MARCHANDO PARA QUE SE LE DE A FINALIZAR Y TERMINA OK
|
||||
|
||||
String msg=string.Empty;
|
||||
//gestiona los flags, el estado de finok o finnok va en res.Vale
|
||||
|
|
@ -24,51 +25,50 @@ namespace OliviaAddInPro.Services
|
|||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecNOk);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = Resource1.String_exito;
|
||||
bool todoOk = true;
|
||||
//importa resultados
|
||||
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
|
||||
{
|
||||
/*if (!gdb.import_secto_ini())
|
||||
{
|
||||
todoOk=false;
|
||||
msg = msg + " " + gdb.err_st;
|
||||
}*/
|
||||
}
|
||||
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
||||
{
|
||||
/*guarda_csv();
|
||||
if (!gdb.import_planif())
|
||||
{
|
||||
todoOk=false;
|
||||
msg = msg + " " + gdb.err_st;
|
||||
}*/
|
||||
}
|
||||
{
|
||||
//actualiza los flags
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecOk);
|
||||
if (todoOk)
|
||||
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecOk);
|
||||
//importa resultados
|
||||
var resp = IniImport();
|
||||
if (resp.HasError)
|
||||
msg = resp.Error.First();
|
||||
else
|
||||
{
|
||||
//pone modo config2
|
||||
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
|
||||
string GdbFileName = resp.Value;
|
||||
var resp2 = new Respuesta<bool> { Value=false};
|
||||
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
|
||||
{
|
||||
resp2 = inst.ServCom.ImportSecto(GdbFileName);
|
||||
}
|
||||
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
|
||||
{
|
||||
GuardaCsv(inst);
|
||||
resp2 = inst.ServCom.ImportPlanif(GdbFileName);
|
||||
}
|
||||
if (!resp2.Value)
|
||||
{
|
||||
msg = resp2.Error.First();
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = Resource1.String_exito;
|
||||
//pone modo config2
|
||||
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
|
||||
}
|
||||
}
|
||||
}
|
||||
//borra los archivos que le toca borrar
|
||||
BorraFiles();
|
||||
HelperGlobal.ponMsg(msg);
|
||||
Application.Current.Dispatcher.Invoke(new Action(() => { finEjecuta2(); }));
|
||||
|
||||
Application.Current.Dispatcher.Invoke(new Action(() => { finEjecuta2(); }));
|
||||
}
|
||||
|
||||
|
||||
public void finEjecuta2()
|
||||
{
|
||||
OliviaGlob.progrDialog.Hide();
|
||||
//muestra la ventana
|
||||
OliviaGlob.ShowHidePane(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Borra los archivos exportados para el proceso
|
||||
|
|
@ -113,5 +113,69 @@ namespace OliviaAddInPro.Services
|
|||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
public static string NAME_CSV = "_L";
|
||||
public static string EXT_CSV = ".csv";
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
string auxi, nombre = null;
|
||||
string[] nameDokL;
|
||||
string DirData = System.IO.Path.GetDirectoryName(OliviaGlob.Paths.PathData);
|
||||
nameDokL = Directory.GetFiles(DirData,
|
||||
System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData) + NAME_CSV + ".*");
|
||||
|
||||
string Title = "Guardar Secuencia de la Planificación";
|
||||
string Filter = "Secuencia en formato CSV (*.csv)|*.csv";
|
||||
inst.decode_gdb(System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData),
|
||||
out auxi, out nombre);
|
||||
string InitialDirectory = System.IO.Path.Combine(DirData, nombre);
|
||||
|
||||
|
||||
string FileName = HelperGdb.SaveFileDlg(Title, InitialDirectory, EXT_CSV, Filter);
|
||||
|
||||
if (string.IsNullOrEmpty(FileName) || FileName.Length == 0)
|
||||
{
|
||||
bool ok = HelperGlobal.ponMsg("Se va a perder el archivo que contiene la secuencia en planificación, ¿está seguro?",
|
||||
MessageBoxImage.Question,"OLIVIA",MessageBoxButton.YesNo);
|
||||
if (!ok)
|
||||
GuardaCsv(inst);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File.Exists(FileName))
|
||||
File.Delete(FileName);
|
||||
File.Move(nameDokL[0], FileName);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Inicializa la importación
|
||||
*/
|
||||
public Respuesta<string> IniImport()
|
||||
{
|
||||
var res = new Respuesta<string>() { Value = string.Empty };
|
||||
//Lanza ventana para elegir gdb a la que importar resultados
|
||||
bool sal = true;
|
||||
string GdbFileName="";
|
||||
do
|
||||
{
|
||||
sal = true;
|
||||
//repite por si se ha equivocado hasta que elige la gdb
|
||||
GdbFileName = HelperGdb.OpenFileDialog(HelperGdb.TiposOpenFileDlg.OpenGdb,"", "Seleccionar GDB a la que importar los resultados");
|
||||
if(string.IsNullOrEmpty(GdbFileName))
|
||||
sal= HelperGlobal.ponMsg("¿Desea cancelar el proceso de imporación?",
|
||||
MessageBoxImage.Question, "OLIVIA", MessageBoxButton.YesNo);
|
||||
} while (!sal);
|
||||
|
||||
if (string.IsNullOrEmpty(GdbFileName) || !Directory.Exists(GdbFileName))
|
||||
{
|
||||
res.Error.Add("Se ha cancelado la importación de resultados.");
|
||||
return res;
|
||||
}
|
||||
res.Value = GdbFileName;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,5 +208,6 @@ namespace OliviaAddInPro.Services
|
|||
}
|
||||
return amb_com;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue