/// <summary> Add a new inner point of interest to this polygon </summary> /// <param name="Latitude"> Latitude (expressed in decimal notation) for this point </param> /// <param name="Longitude"> Longitude (expressed in decimal notation) for this point </param> /// <param name="Label"> Label to associate with this point </param> /// <returns> Fully built Coordinate_Point object </returns> public Coordinate_Point Add_Inner_Point(double Latitude, double Longitude, string Label) { Coordinate_Point newPoint = new Coordinate_Point(Latitude, Longitude, Label); internal_points.Add(newPoint); return(newPoint); }
/// <summary> Adds a new point to this line, including altitude</summary> /// <param name="Latitude"> Latitude (expressed in decimal notation) for this point </param> /// <param name="Longitude"> Longitude (expressed in decimal notation) for this point </param> /// <param name="Label"> Label to associate with this point </param> /// <param name="Altitude"> Altitude for this point on a 3-dimensional plane (in meters)</param> /// <returns>Fully built and added point object </returns> public Coordinate_Point Add_Point(double Latitude, double Longitude, string Label, long Altitude) { Coordinate_Point newPoint = new Coordinate_Point(Latitude, Longitude, Label, Altitude); points.Add(newPoint); return(newPoint); }
/// <summary> Add a new edge point of interest to this polygon </summary> /// <param name="newPoint"> Built coordinate point object to add </param> public void Add_Edge_Point(Coordinate_Point newPoint) { // Update the current bounding box, if there is one if (bounding_box != null) { bounding_box = null; } edge_points.Add(newPoint); }
/// <summary> Add a new edge point of interest to this polygon </summary> /// <param name="Latitude"> Latitude (expressed in decimal notation) for this point </param> /// <param name="Longitude"> Longitude (expressed in decimal notation) for this point </param> /// <param name="Label"> Label to associate with this point </param> /// <returns> Fully built Coordinate_Point object </returns> public Coordinate_Point Add_Edge_Point(double Latitude, double Longitude, string Label) { // Update the current bounding box, if there is one if (bounding_box != null) { bounding_box = null; } Coordinate_Point newPoint = new Coordinate_Point(Latitude, Longitude, Label); edge_points.Add(newPoint); return(newPoint); }
/// <summary> Add a single, completely built point associated with this digital resource </summary> /// <param name="Point"> Coordinate line object associated with this digital resource </param> public void Add_Point(Coordinate_Point Point) { // Only add this point if it does not already exists if (points == null) { points = new List <Coordinate_Point>(); } foreach (Coordinate_Point existingPoint in points) { if ((existingPoint.Latitude == Point.Latitude) && (existingPoint.Longitude == Point.Longitude)) { return; } } if (Point != null) { points.Add(Point); } }
private static Coordinate_Point read_point(XmlReader Input_XmlReader) { try { Coordinate_Point newPoint = new Coordinate_Point(); if (Input_XmlReader.MoveToAttribute("latitude")) newPoint.Latitude = Convert.ToDouble(Input_XmlReader.Value.Replace("°", "")); if (Input_XmlReader.MoveToAttribute("longitude")) newPoint.Longitude = Convert.ToDouble(Input_XmlReader.Value.Replace("°", "")); if (Input_XmlReader.MoveToAttribute("altitude")) { try { newPoint.Altitude = (long) Convert.ToDouble(Input_XmlReader.Value); } catch { } } if (Input_XmlReader.MoveToAttribute("order")) { try { newPoint.Order_From_XML_Read = Convert.ToInt32(Input_XmlReader.Value); } catch { } } if (Input_XmlReader.MoveToAttribute("label")) newPoint.Label = Input_XmlReader.Value; return newPoint; } catch { return null; } }
/// <summary> Add a new inner point of interest to this polygon </summary> /// <param name="Latitude"> Latitude (expressed in decimal notation) for this point </param> /// <param name="Longitude"> Longitude (expressed in decimal notation) for this point </param> /// <param name="Label"> Label to associate with this point </param> /// <returns> Fully built Coordinate_Point object </returns> public Coordinate_Point Add_Inner_Point(double Latitude, double Longitude, string Label) { Coordinate_Point newPoint = new Coordinate_Point(Latitude, Longitude, Label); internal_points.Add(newPoint); return newPoint; }
/// <summary> Add a new inner point of interest to this polygon </summary> /// <param name="newPoint"> Built coordinate point object to add </param> public void Add_Inner_Point(Coordinate_Point newPoint) { internal_points.Add(newPoint); }
/// <summary> Add a new edge point of interest to this polygon </summary> /// <param name="Latitude"> Latitude (expressed in decimal notation) for this point </param> /// <param name="Longitude"> Longitude (expressed in decimal notation) for this point </param> /// <param name="Label"> Label to associate with this point </param> /// <returns> Fully built Coordinate_Point object </returns> public Coordinate_Point Add_Edge_Point(double Latitude, double Longitude, string Label) { // Update the current bounding box, if there is one if (bounding_box != null) { bounding_box = null; } Coordinate_Point newPoint = new Coordinate_Point(Latitude, Longitude, Label); edge_points.Add(newPoint); return newPoint; }
/// <summary> Adds a new point to this line, including altitude</summary> /// <param name="Latitude"> Latitude (expressed in decimal notation) for this point </param> /// <param name="Longitude"> Longitude (expressed in decimal notation) for this point </param> /// <param name="Label"> Label to associate with this point </param> /// <param name="Altitude"> Altitude for this point on a 3-dimensional plane (in meters)</param> /// <returns>Fully built and added point object </returns> public Coordinate_Point Add_Point(double Latitude, double Longitude, string Label, long Altitude) { Coordinate_Point newPoint = new Coordinate_Point(Latitude, Longitude, Label, Altitude); points.Add(newPoint); return newPoint; }
/// <summary> Add a single, completely built point associated with this digital resource </summary> /// <param name="Point"> Coordinate line object associated with this digital resource </param> public void Add_Point(Coordinate_Point Point) { // Only add this point if it does not already exists if (points == null) points = new List<Coordinate_Point>(); foreach (Coordinate_Point existingPoint in points) if ((existingPoint.Latitude == Point.Latitude) && (existingPoint.Longitude == Point.Longitude)) return; if (Point != null) points.Add(Point); }
private void Compute_SobekCM_Main_Spatial() { // Set the distance to zero initially sobekcm_main_spatial_distance = 0; // Fields to hold the boundary positions double least_latitude = 0; double most_latitude = 0; double least_longitude = 0; double most_longitude = 0; // Build the spatial_kml for this StringBuilder spatial_kml_builder = new StringBuilder(50); string spatial_kml = String.Empty; try { // Check for areas first if (Polygon_Count > 0) { // If only one polygon, easy to assign if (Polygon_Count == 1) { spatial_kml_builder.Append("A|"); Coordinate_Point first_point = Get_Polygon(0).Edge_Points[0]; least_latitude = first_point.Latitude; most_latitude = first_point.Latitude; least_longitude = first_point.Longitude; most_longitude = first_point.Longitude; foreach (Coordinate_Point thisPoint in Get_Polygon(0).Edge_Points) { if (thisPoint.Latitude < least_latitude) { least_latitude = thisPoint.Latitude; } if (thisPoint.Latitude > most_latitude) { most_latitude = thisPoint.Latitude; } if (thisPoint.Longitude < least_longitude) { least_longitude = thisPoint.Longitude; } if (thisPoint.Longitude > most_longitude) { most_longitude = thisPoint.Longitude; } if (spatial_kml_builder.Length > 2) { spatial_kml_builder.Append("|"); } spatial_kml_builder.Append(thisPoint.Latitude + "," + thisPoint.Longitude); } } else { // Try to find the display polygon Coordinate_Polygon polygon = null; for (int i = 0; i < Polygon_Count; i++) { Coordinate_Polygon thisPolygon = Get_Polygon(i); if ((thisPolygon.Label.ToUpper().IndexOf("DISPLAY") >= 0) || (thisPolygon.Label.ToUpper().IndexOf("MAIN") >= 0)) { polygon = thisPolygon; break; } } if (polygon != null) { // Either a DISPLAY or MAIN polygon was found spatial_kml_builder.Append("A|"); foreach (Coordinate_Point thisPoint in polygon.Edge_Points) { if (spatial_kml_builder.Length > 2) { spatial_kml_builder.Append("|"); } spatial_kml_builder.Append(thisPoint.Latitude + "," + thisPoint.Longitude); } ReadOnlyCollection <Coordinate_Point> bounding_boxes = polygon.Bounding_Box; if (bounding_boxes.Count == 2) { least_latitude = Math.Min(bounding_boxes[0].Latitude, bounding_boxes[1].Latitude); most_latitude = Math.Max(bounding_boxes[0].Latitude, bounding_boxes[1].Latitude); least_longitude = Math.Min(bounding_boxes[0].Longitude, bounding_boxes[1].Longitude); most_longitude = Math.Max(bounding_boxes[0].Longitude, bounding_boxes[1].Longitude); } } else { // Determine a bounding box then Coordinate_Polygon polygon2 = Get_Polygon(0); Coordinate_Point first_point = polygon2.Bounding_Box[0]; least_latitude = first_point.Latitude; most_latitude = first_point.Latitude; least_longitude = first_point.Longitude; most_longitude = first_point.Longitude; foreach (Coordinate_Point thisPoint in polygon2.Bounding_Box) { if (thisPoint.Latitude < least_latitude) { least_latitude = thisPoint.Latitude; } if (thisPoint.Latitude > most_latitude) { most_latitude = thisPoint.Latitude; } if (thisPoint.Longitude < least_longitude) { least_longitude = thisPoint.Longitude; } if (thisPoint.Longitude > most_longitude) { most_longitude = thisPoint.Longitude; } } for (int i = 1; i < Polygon_Count; i++) { Coordinate_Polygon thisPolygon = Get_Polygon(i); foreach (Coordinate_Point thisPoint in thisPolygon.Bounding_Box) { if (thisPoint.Latitude < least_latitude) { least_latitude = thisPoint.Latitude; } if (thisPoint.Latitude > most_latitude) { most_latitude = thisPoint.Latitude; } if (thisPoint.Longitude < least_longitude) { least_longitude = thisPoint.Longitude; } if (thisPoint.Longitude > most_longitude) { most_longitude = thisPoint.Longitude; } } } if ((least_latitude != most_latitude) || (least_longitude != most_longitude)) { spatial_kml_builder.Append("A|" + least_latitude + "," + least_longitude + "|" + most_latitude + "," + most_longitude); } else { spatial_kml_builder.Append("P|" + least_latitude + "," + least_longitude); } } } // Since this is an area, compute the greatest distance double latitude_distance = Math.Abs(most_latitude - least_latitude); double longitude_distance = Math.Abs(most_longitude - least_longitude); sobekcm_main_spatial_distance = Math.Sqrt(Math.Pow(latitude_distance, 2) + Math.Pow(longitude_distance, 2)); } } catch { } try { // Try to build the spatial kml from points if there was no area possible if ((spatial_kml_builder.Length == 0) && (Point_Count > 0)) { // If only one point, this is easy! if (Point_Count == 1) { Coordinate_Point thisPoint = points[0]; spatial_kml_builder.Append("P|" + thisPoint.Latitude + "," + thisPoint.Longitude); } else { Coordinate_Point first_point = points[0]; least_latitude = Convert.ToDouble(first_point.Latitude); most_latitude = least_latitude; least_longitude = Convert.ToDouble(first_point.Longitude); most_longitude = least_latitude; foreach (Coordinate_Point thisPoint in points) { if (thisPoint.Latitude < least_latitude) { least_latitude = thisPoint.Latitude; } if (thisPoint.Latitude > most_latitude) { most_latitude = thisPoint.Latitude; } if (thisPoint.Longitude < least_longitude) { least_longitude = thisPoint.Longitude; } if (thisPoint.Longitude > most_longitude) { most_longitude = thisPoint.Longitude; } } if ((least_latitude != most_latitude) || (least_longitude != most_longitude)) { spatial_kml_builder.Append("A|" + least_latitude + "," + least_longitude + "|" + most_latitude + "," + most_longitude); // Since this is really points, we'll not chane the distance value from zero } else { spatial_kml_builder.Append("P|" + least_latitude + "," + least_longitude); } } } } catch { } sobekcm_main_spatial_string = spatial_kml_builder.ToString(); }
/// <summary>Add a pre-existing point object to this line </summary> /// <param name="newPoint"> New point to add to this line </param> public void Add_Point(Coordinate_Point newPoint) { points.Add(newPoint); }
/// <summary> parse and save incoming message </summary> /// <param name="SendData"> message from page </param> public static void SaveContent(String SendData) { try { //get rid of excess string SendData = SendData.Replace("{\"sendData\": \"", "").Replace("{\"sendData\":\"", ""); //validate if (SendData.Length == 0) return; //ensure we have a geo-spatial module in the digital resource GeoSpatial_Information resourceGeoInfo = currentItem.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; //if there was no geo-spatial module if (resourceGeoInfo == null) { //create new geo-spatial module, if we do not already have one resourceGeoInfo = new GeoSpatial_Information(); currentItem.Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, resourceGeoInfo); } //get the pages List<abstract_TreeNode> pages = currentItem.Divisions.Physical_Tree.Pages_PreOrder; //create a new list of all the polygons for a resource item Dictionary<string, Page_TreeNode> pageLookup = new Dictionary<string, Page_TreeNode>(); int page_index = 1; foreach (var abstractTreeNode in pages) { var pageNode = (Page_TreeNode) abstractTreeNode; if (pageNode.Label.Length == 0) pageLookup["Page " + page_index] = pageNode; else pageLookup[pageNode.Label] = pageNode; page_index++; } //get the length of incoming message int index1 = SendData.LastIndexOf("~", StringComparison.Ordinal); //split into each save message string[] allSaves = SendData.Substring(0, index1).Split('~'); //hold save type handle string saveTypeHandle; //go through each item to save and check for ovelrays and item only not pois (ORDER does matter because these will be saved to db before pois are saved) foreach (string t in allSaves) { //get the length of save message int index2 = t.LastIndexOf("|", StringComparison.Ordinal); //split into save elements string[] ar = t.Substring(0, index2).Split('|'); //determine the save type handle (position 0 in array) saveTypeHandle = ar[0]; //determine the save type (position 1 in array) string saveType = ar[1]; //based on saveType, parse into objects if (saveTypeHandle == "save") { //handle save based on type switch (saveType) { #region item case "item": //prep incoming lat/long string[] temp1 = ar[2].Split(','); double temp1Lat = Convert.ToDouble(temp1[0].Replace("(", "")); double temp1Long = Convert.ToDouble(temp1[1].Replace(")", "")); ////clear specific geo obj //resourceGeoInfo.Clear_Specific(Convert.ToString(ar[3])); //clear all the previous mains featureTypes (this will work for an item because there is only ever one item) resourceGeoInfo.Clear_NonPOIs(); //add the point obj Coordinate_Point newPoint = new Coordinate_Point(temp1Lat, temp1Long, currentItem.METS_Header.ObjectID, "main"); //add the new point resourceGeoInfo.Add_Point(newPoint); //save to db SobekCM_Database.Save_Digital_Resource(currentItem, options); break; #endregion #region overlay case "overlay": //parse the array id of the page int arrayId = (Convert.ToInt32(ar[2]) - 1); //is this always true (minus one of the human page id)? //add the label to page obj pages[arrayId].Label = ar[3]; //get the geocoordinate object for that pageId GeoSpatial_Information pageGeo = pages[arrayId].Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; //if there isnt any already there if (pageGeo == null) { //create new pageGeo = new GeoSpatial_Information(); //create a polygon Coordinate_Polygon pagePolygon = new Coordinate_Polygon(); //prep incoming bounds string[] temp2 = ar[4].Split(','); pagePolygon.Clear_Edge_Points(); pagePolygon.Add_Edge_Point(Convert.ToDouble(temp2[0].Replace("(", "")), Convert.ToDouble(temp2[1].Replace(")", ""))); pagePolygon.Add_Edge_Point(Convert.ToDouble(temp2[2].Replace("(", "")), Convert.ToDouble(temp2[3].Replace(")", ""))); pagePolygon.Recalculate_Bounding_Box(); //add the rotation double result; pagePolygon.Rotation = Double.TryParse(ar[6], out result) ? result : 0; //add the featureType (explicitly add to make sure it is there) pagePolygon.FeatureType = "main"; //add the label pagePolygon.Label = ar[3]; //add the polygon type pagePolygon.PolygonType = "rectangle"; //add polygon to pagegeo pageGeo.Add_Polygon(pagePolygon); } else { try { //get current polygon info Coordinate_Polygon pagePolygon = pageGeo.Polygons[0]; //prep incoming bounds string[] temp2 = ar[4].Split(','); pagePolygon.Clear_Edge_Points(); pagePolygon.Add_Edge_Point(Convert.ToDouble(temp2[0].Replace("(", "")), Convert.ToDouble(temp2[1].Replace(")", ""))); pagePolygon.Add_Edge_Point(Convert.ToDouble(temp2[2].Replace("(", "")), Convert.ToDouble(temp2[3].Replace(")", ""))); pagePolygon.Recalculate_Bounding_Box(); //add the rotation double result; pagePolygon.Rotation = Double.TryParse(ar[6], out result) ? result : 0; //add the featureType (explicitly add to make sure it is there) pagePolygon.FeatureType = "main"; //add the label pagePolygon.Label = ar[3]; //add the polygon type pagePolygon.PolygonType = "rectangle"; //clear all previous nonPOIs for this page (NOTE: this will only work if there is only one main page item) pageGeo.Clear_NonPOIs(); //add polygon to pagegeo pageGeo.Add_Polygon(pagePolygon); } catch (Exception) { //there were no polygons try { //make a polygon Coordinate_Polygon pagePolygon = new Coordinate_Polygon(); //prep incoming bounds string[] temp2 = ar[4].Split(','); pagePolygon.Clear_Edge_Points(); pagePolygon.Add_Edge_Point(Convert.ToDouble(temp2[0].Replace("(", "")), Convert.ToDouble(temp2[1].Replace(")", ""))); pagePolygon.Add_Edge_Point(Convert.ToDouble(temp2[2].Replace("(", "")), Convert.ToDouble(temp2[3].Replace(")", ""))); pagePolygon.Recalculate_Bounding_Box(); //add the rotation double result; pagePolygon.Rotation = Double.TryParse(ar[6], out result) ? result : 0; //add the featureType (explicitly add to make sure it is there) pagePolygon.FeatureType = "main"; //add the label pagePolygon.Label = ar[3]; //add the polygon type pagePolygon.PolygonType = "rectangle"; //clear all previous nonPOIs for this page (NOTE: this will only work if there is only one main page item) pageGeo.Clear_NonPOIs(); //add polygon to pagegeo pageGeo.Add_Polygon(pagePolygon); } catch (Exception) { //welp... } } } //add the pagegeo obj pages[arrayId].Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, pageGeo); //save to db SobekCM_Database.Save_Digital_Resource(currentItem, options); break; #endregion } } else { if (saveTypeHandle == "delete") { switch (saveType) { #region item case "item": //clear nonpoipoints resourceGeoInfo.Clear_NonPOIPoints(); //save to db SobekCM_Database.Save_Digital_Resource(currentItem, options); break; #endregion #region overlay case "overlay": try { //parse the array id of the page int arrayId = (Convert.ToInt32(ar[2]) - 1); //is this always true (minus one of the human page id)? //get the geocoordinate object for that pageId GeoSpatial_Information pageGeo = pages[arrayId].Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information; if (pageGeo != null) { Coordinate_Polygon pagePolygon = pageGeo.Polygons[0]; //reset edgepoints pagePolygon.Clear_Edge_Points(); //reset rotation pagePolygon.Rotation = 0; //add the featureType (explicitly add to make sure it is there) pagePolygon.FeatureType = "hidden"; //add the polygon type pagePolygon.PolygonType = "hidden"; //clear all previous nonPOIs for this page (NOTE: this will only work if there is only one main page item) pageGeo.Clear_NonPOIs(); //add polygon to pagegeo pageGeo.Add_Polygon(pagePolygon); } ////if there isnt any already there //if (pageGeo != null) // pageGeo.Remove_Polygon(pageGeo.Polygons[0]); //add the pagegeo obj pages[arrayId].Add_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY, pageGeo); //save to db SobekCM_Database.Save_Digital_Resource(currentItem, options); } catch (Exception) { // } break; #endregion } } } } //check to see if save poi clear has already been fired... bool firedOnce = true; //go through each item to save and check for pois only foreach (string t in allSaves) { //get the length of save message int index2 = t.LastIndexOf("|", StringComparison.Ordinal); //split into save elements string[] ar = t.Substring(0, index2).Split('|'); //determine the save type handle (position 0 in array) saveTypeHandle = ar[0]; //determine the save type (position 1 in array) string saveType = ar[1]; //based on saveType, parse into objects if (saveTypeHandle == "save") { //handle save based on type switch (saveType) { #region poi case "poi": //fixes bug if (firedOnce) { //clear previous poi points resourceGeoInfo.Clear_POIs(); firedOnce = false; } //get specific geometry (KML Standard) switch (ar[2]) { case "marker": //prep incoming lat/long string[] temp2 = ar[4].Split(','); double temp2Lat = Convert.ToDouble(temp2[0].Replace("(", "")); double temp2Long = Convert.ToDouble(temp2[1].Replace(")", "")); //add the new point resourceGeoInfo.Add_Point(temp2Lat, temp2Long, ar[3], "poi"); break; case "circle": //create new circle Coordinate_Circle poiCircle = new Coordinate_Circle {Label = ar[3], Radius = Convert.ToDouble(ar[5]), FeatureType = "poi"}; //add the incoming lat/long string[] temp3 = ar[4].Split(','); poiCircle.Latitude = Convert.ToDouble(temp3[0].Replace("(", "")); poiCircle.Longitude = Convert.ToDouble(temp3[1].Replace(")", "")); //add to the resource obj resourceGeoInfo.Add_Circle(poiCircle); break; case "rectangle": //create new polygon Coordinate_Polygon poiRectangle = new Coordinate_Polygon {Label = ar[3], FeatureType = "poi", PolygonType = "rectangle"}; //add the incoming bounds string[] temp4 = ar[4].Split(','); poiRectangle.Add_Edge_Point(Convert.ToDouble(temp4[0].Replace("(", "")), Convert.ToDouble(temp4[1].Replace(")", ""))); poiRectangle.Add_Edge_Point(Convert.ToDouble(temp4[2].Replace("(", "")), Convert.ToDouble(temp4[3].Replace(")", ""))); poiRectangle.Recalculate_Bounding_Box(); //add to resource obj resourceGeoInfo.Add_Polygon(poiRectangle); break; case "polygon": //create new polygon Coordinate_Polygon poiPolygon = new Coordinate_Polygon {Label = ar[3], FeatureType = "poi"}; //add the edge points for (int i2 = 5; i2 < ar.Length; i2++) { string[] temp5 = ar[i2].Split(','); poiPolygon.Add_Edge_Point(Convert.ToDouble(temp5[0].Replace("(", "")), Convert.ToDouble(temp5[1].Replace(")", ""))); } //add the polygon resourceGeoInfo.Add_Polygon(poiPolygon); break; case "polyline": //create new line Coordinate_Line poiLine = new Coordinate_Line {Label = ar[3], FeatureType = "poi"}; //add the edge points for (int i2 = 5; i2 < ar.Length; i2++) { string[] temp5 = ar[i2].Split(','); poiLine.Add_Point(Convert.ToDouble(temp5[0].Replace("(", "")), Convert.ToDouble(temp5[1].Replace(")", "")), ""); } //add the line resourceGeoInfo.Add_Line(poiLine); break; } break; #endregion } } } #region prep saving dir //create inprocessing directory string userInProcessDirectory = UI_ApplicationCache_Gateway.Settings.User_InProcess_Directory( currentUser, "mapwork"); string backupDirectory = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + currentItem.Web.AssocFilePath + UI_ApplicationCache_Gateway.Settings.Resources.Backup_Files_Folder_Name; //ensure the user's process directory exists if (!Directory.Exists(userInProcessDirectory)) Directory.CreateDirectory(userInProcessDirectory); //ensure the backup directory exists if (!Directory.Exists(backupDirectory)) Directory.CreateDirectory(backupDirectory); string resource_directory = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + currentItem.Web.AssocFilePath; string current_mets = resource_directory + currentItem.METS_Header.ObjectID + ".mets.xml"; string backup_mets = backupDirectory + "\\" + currentItem.METS_Header.ObjectID + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".mets.xml.BAK"; string metsInProcessFile = userInProcessDirectory + "\\" + currentItem.BibID + "_" + currentItem.VID + ".mets.xml"; #endregion #region Save mets and db //save the item to the temporary location currentItem.Save_METS(userInProcessDirectory + "\\" + currentItem.BibID + "_" + currentItem.VID + ".mets.xml"); //move temp mets to prod File.Copy(metsInProcessFile, current_mets, true); //delete in process mets file File.Delete(metsInProcessFile); //create a backup mets file File.Copy(current_mets, backup_mets, true); #endregion } catch (Exception) { //Custom_Tracer.Add_Trace("MapEdit Save Error"); throw new ApplicationException("MapEdit Save Error"); //throw; } }