/// <summary> /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible /// </summary> public GisFeature(GisUploadAttempt gisUploadAttempt, DbGeometry gisFeatureGeometry, int gisImportFeatureKey) : this() { // Mark this as a new object by setting primary key with special value this.GisFeatureID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue(); this.GisUploadAttemptID = gisUploadAttempt.GisUploadAttemptID; this.GisUploadAttempt = gisUploadAttempt; gisUploadAttempt.GisFeatures.Add(this); this.GisFeatureGeometry = gisFeatureGeometry; this.GisImportFeatureKey = gisImportFeatureKey; }
public override bool IsComplete(GisUploadAttempt gisUploadAttempt) { if (gisUploadAttempt == null) { return(false); } //var basicsResults = new BasicsViewModel(project).GetValidationResults(); //return !basicsResults.Any(); return(true); }
/// <summary> /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible /// </summary> public GisUploadAttemptGisMetadataAttribute(GisUploadAttempt gisUploadAttempt, GisMetadataAttribute gisMetadataAttribute, int sortOrder) : this() { // Mark this as a new object by setting primary key with special value this.GisUploadAttemptGisMetadataAttributeID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue(); this.GisUploadAttemptID = gisUploadAttempt.GisUploadAttemptID; this.GisUploadAttempt = gisUploadAttempt; gisUploadAttempt.GisUploadAttemptGisMetadataAttributes.Add(this); this.GisMetadataAttributeID = gisMetadataAttribute.GisMetadataAttributeID; this.GisMetadataAttribute = gisMetadataAttribute; gisMetadataAttribute.GisUploadAttemptGisMetadataAttributes.Add(this); this.SortOrder = sortOrder; }
public static string SaveFileToDiskIfGdb(HttpPostedFileBase httpPostedFileBase, GisUploadAttempt gisUploadAttempt) { GisUploadAttemptStaging.SetupDirectory(gisUploadAttempt); var fileEnding = Path.GetFileName(httpPostedFileBase.FileName); var fullFilePath = Path.Combine(GisUploadAttemptStaging.GisUploadAttemptDirectory(gisUploadAttempt), fileEnding); httpPostedFileBase.SaveAs(fullFilePath); return(fullFilePath); }
public static void SetupDirectory(GisUploadAttempt gisUploadAttempt) { if (!System.IO.Directory.Exists(GetGisFileRootDirectory())) { System.IO.Directory.CreateDirectory(GetGisFileRootDirectory()); } if (!System.IO.Directory.Exists(GisUploadAttemptDirectory(gisUploadAttempt))) { System.IO.Directory.CreateDirectory(GisUploadAttemptDirectory(gisUploadAttempt)); } var fileInfos = new DirectoryInfo(GisUploadAttemptDirectory(gisUploadAttempt)).GetFiles().ToList(); fileInfos.ForEach(f => f.Delete()); }
public override string GetSectionUrl(GisUploadAttempt gisUploadAttempt) { return(gisUploadAttempt != null ? SitkaRoute <ProjectCreateController> .BuildUrlFromExpression(x => x.EditBasics(gisUploadAttempt.GisUploadAttemptID)) : null); }
public abstract string GetSectionUrl(GisUploadAttempt gisUploadAttempt);
public abstract bool IsComplete(GisUploadAttempt gisUploadAttempt);
public override string GetSectionUrl(GisUploadAttempt gisUploadAttempt) { return(gisUploadAttempt != null ? SitkaRoute <GisProjectBulkUpdateController> .BuildUrlFromExpression(x => x.UploadGisFile(gisUploadAttempt.GisUploadAttemptID)) : null); }
public static string UnzipAndSaveFileToDiskIfShapefile(HttpPostedFileBase httpPostedFileBase, GisUploadAttempt gisUploadAttempt, ref bool shapeFileSuccessfullyExtractedToDisk) { ZipFile zipFile = null; var shapeFilePath = string.Empty; var zipFailure = false; try { zipFile = new ZipFile(httpPostedFileBase.InputStream); } catch (Exception) { zipFailure = true; } if (!zipFailure && zipFile != null) { GisUploadAttemptStaging.SetupDirectory(gisUploadAttempt); var extensionsFound = new List <string>(); var shapeFilePathCreated = false; foreach (ZipEntry zipEntry in zipFile) { if (!zipEntry.IsFile) { continue; } var extension = Path.GetExtension(zipEntry.Name); if (ValidExtensions.Any(e => e == extension)) { if (extensionsFound.All(e => e != extension)) { extensionsFound.Add(extension); } var shapefileNameWithExtension = Path.GetFileName(zipEntry.Name); if (shapefileNameWithExtension == null) { continue; } // this file is a "keeper", extract it and write it to disk var fullFilePath = Path.Combine(GisUploadAttemptStaging.GisUploadAttemptDirectory(gisUploadAttempt), shapefileNameWithExtension); if (extension.Equals(".shp")) { shapeFilePath = fullFilePath; shapeFilePathCreated = true; } var buffer = new byte[4096]; // 4K is optimum var zipStream = zipFile.GetInputStream(zipEntry); // unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size of the file, but does not waste memory using (var streamWriter = System.IO.File.Create(fullFilePath)) { StreamUtils.Copy(zipStream, streamWriter, buffer); } } } shapeFileSuccessfullyExtractedToDisk = extensionsFound.Count == ValidExtensions.Count && shapeFilePathCreated; } return(shapeFilePath); }
public abstract List <GisUploadAttemptWorkflowSectionSimple> GetGisUploadAttemptWorkflowSections(GisUploadAttempt gisUploadAttempt, bool ignoreStatus);
public static string GisUploadAttemptDirectory(GisUploadAttempt gisUploadAttempt) { return(Path.Combine(GetGisFileRootDirectory(), gisUploadAttempt.GisUploadAttemptID.ToString())); }
/// <summary> /// Creates a "blank" object of this type and populates primitives with defaults /// </summary> public static GisUploadAttemptGisMetadataAttribute CreateNewBlank(GisUploadAttempt gisUploadAttempt, GisMetadataAttribute gisMetadataAttribute) { return(new GisUploadAttemptGisMetadataAttribute(gisUploadAttempt, gisMetadataAttribute, default(int))); }
public static void DeleteGisUploadAttempt(this IQueryable <GisUploadAttempt> gisUploadAttempts, GisUploadAttempt gisUploadAttemptToDelete) { DeleteGisUploadAttempt(gisUploadAttempts, new List <GisUploadAttempt> { gisUploadAttemptToDelete }); }
protected List <GisUploadAttemptWorkflowSectionSimple> GetGisUploadAttemptWorkflowSectionsImpl(GisUploadAttempt gisUploadAttempt, List <GisUploadAttemptWorkflowSection> gisUploadAttemptWorkflowSections, bool ignoreStatus) { return(gisUploadAttemptWorkflowSections.Select(x => new GisUploadAttemptWorkflowSectionSimple(x, x.GetSectionUrl(gisUploadAttempt), !ignoreStatus && x.IsComplete(gisUploadAttempt), false, gisUploadAttempt != null && x.HasCompletionStatus)).OrderBy(x => x.SortOrder).ToList()); }
/// <summary> /// Creates a "blank" object of this type and populates primitives with defaults /// </summary> public static GisFeature CreateNewBlank(GisUploadAttempt gisUploadAttempt) { return(new GisFeature(gisUploadAttempt, default(DbGeometry), default(int))); }
public override List <GisUploadAttemptWorkflowSectionSimple> GetGisUploadAttemptWorkflowSections(GisUploadAttempt gisUploadAttempt, bool ignoreStatus) { return(GetGisUploadAttemptWorkflowSectionsImpl(gisUploadAttempt, GisUploadAttemptWorkflowSections, ignoreStatus)); }