/// <summary> /// It updates the Existing dataView of Map object with new DataView for Drilled Down AreasNIds specified. /// </summary> private static void MergeDataOfDrilledDownAreas(string areaNIds, string areaIDs, Map map) { UI.UserPreference.UserPreference UserPreference2 = null; UI.DataViewPage.DIDataView DIDataView2 = null; DataTable MRDTable = null; string areaIDsWithQuotes = string.Empty; if (map != null && string.IsNullOrEmpty(areaNIds) == false && string.IsNullOrEmpty(areaIDs) == false) { //-- Create new UserPreference with new areas but having same IUS, TimePeriod, Source. UserPreference2 = (UI.UserPreference.UserPreference)(map._UserPreference.Clone()); areaIDsWithQuotes = "'" + areaIDs.Replace(",", "','") + "'"; UserPreference2.UserSelection.AreaIds = areaIDs; UserPreference2.UserSelection.AreaNIds = areaNIds; //-- Create new DIDataView with new UserPreference. DIDataView2 = new DIDataView(UserPreference2, map.DIConnection, map.DIQueries, Path.Combine(map.UserPreference.General.AdaptationPath, @"Bin\Templates\Metadata\Mask"), string.Empty); DIDataView2.GetAllDataByUserSelection(); if (DIDataView2.MainDataTable != null && DIDataView2.MainDataTable.Columns.Count > 0) { MRDTable = DIDataView2.GetMostRecentData(false).Table; //-- Merge new DataView with existing Map's DataView map._DIDataView.MainDataTable.Merge(DIDataView2.MainDataTable); //-- Re-assign PresentationData & MRDData map._PresentationData.Table.Merge(DIDataView2.MainDataTable); map.MRDData.Table.Merge(MRDTable); } } }
/// <summary> /// Get Image for the selected area /// </summary> /// <param name="AreaNId"> Area Nid of selected area</param> /// <param name="OutPath"> Location where metadata related files are created</param> /// <param name="DI_QueryBase"> This contain Conncetion Details</param> /// <param name="PicHeight"> Height of the map </param> /// <param name="PicWidth">width of the map</param> /// <returns></returns> public static Image GetAreaMapImage(DIConnection DIConnection, DIQueries DIQueries, int AreaNId, string TempFolder, int PicHeight, int PicWidth) { Image RetVal = null; int LayerNId = -1; try { //-- If any specific layer has not been defined then get the first base layer associated with the area if (_LayerNId == -1) { LayerNId = GetLayerNId(AreaNId.ToString(), DIConnection, DIQueries); } else { LayerNId = _LayerNId; } if (LayerNId != -1) { //Get Layer Name string LayerName = GetLayerName(LayerNId.ToString(), DIConnection, DIQueries); //Extarct shape file for associated layer Map.ExtractShapeFileByLayerId(LayerNId.ToString(), TempFolder, DIConnection, DIQueries); Map map = new Map(); map.CanvasColor = Color.White; // Add layer to map layer collection map.Layers.Clear(); map.Width = PicWidth; map.Height = PicHeight; map.Layers.AddShapeFile(TempFolder, LayerName); map.Layers[0].FillColor = System.Drawing.Color.White; map.SetFullExtent(); //Extract map image RetVal = Image.FromStream(map.GetMapStream()); map.Dispose(); map = null; } } catch (Exception ex) { Console.Write(ex.Message); } return RetVal; }