Esempio n. 1
0
        public StrategyGroup ToEntity()
        {
            StrategyGroup strategyGroup = Mapper.Map <StrategyGroupViewModel, StrategyGroup>(this);

            if (ImageFile != null)
            {
                // original image
                MemoryStream memoryStream = new MemoryStream();
                ImageFile.InputStream.CopyTo(memoryStream);
                byte[] originalImageContent = memoryStream.ToArray();
                strategyGroup.OriginalImage = new Image
                {
                    Content = originalImageContent,
                    Type    = ImageFile.ContentType
                };

                // thumbnail image
                byte[] thumbnailImageContent = ThumbnailHelper.CreateThumbnail(originalImageContent);
                strategyGroup.ThumbnailImage = new Image
                {
                    Content = thumbnailImageContent,
                    Type    = ImageFile.ContentType
                };
            }

            return(strategyGroup);
        }
Esempio n. 2
0
        public string GetThumbnial(string name, string strBBox)
        {
            #region [生成缩略图]

            ThumbnailHelper tbh = new ThumbnailHelper();
            return(tbh.CreateThumbnail(name, "map", strBBox));


            #endregion
        }
Esempio n. 3
0
    private static string GenerateThumbnail(string imageFileName)
    {
        var    fc = FileCache.GetInstance();
        string thumbnailFileName = fc.GetPublicTempFileName(".jpg");

        ThumbnailHelper.CreateThumbnail(imageFileName,
                                        fc.GetAbsolutePublicCachePath(thumbnailFileName),
                                        new System.Drawing.Size(40, 40), true);
        return(fc.GetRelativePublicCachePath(thumbnailFileName));
    }
Esempio n. 4
0
 /// <summary>
 /// 下载缩略图
 /// </summary>
 /// <param name="name"></param>
 /// <param name="type"></param>
 /// <param name="bbox"></param>
 public void ThumbnailCreate(string name, string type, string bbox)
 {
     try
     {
         ThumbnailHelper tbh       = new ThumbnailHelper();
         string          imagePath = tbh.CreateThumbnail(name, type, bbox);
     }
     catch (Exception ex)
     {
         logger.Info(UtilityMessageConvert.Get("缩略图下载异常:图层名称") + "(" + name + ")" + ex.Message);
     }
 }
Esempio n. 5
0
 private string CreateThumbnail(string filePath)
 {
     if (File.Exists(filePath))
     {
         var    fc = Aurigma.GraphicsMill.AjaxControls.FileCache.GetInstance();
         string thumbnailFileName = fc.GetPublicTempFileName(".jpg");
         ThumbnailHelper.CreateThumbnail(filePath,
                                         fc.GetAbsolutePublicCachePath(thumbnailFileName),
                                         new System.Drawing.Size(40, 40), true);
         return(fc.GetRelativePublicCachePath(thumbnailFileName));
     }
     else
     {
         return(null);
     }
 }
Esempio n. 6
0
        private string CreateThumbnail(string filePath)
        {
            if (File.Exists(filePath))
            {
                var fc = FileCache.GetInstance();

                var thumbnailFileName = fc.GetPublicTempFileName(".gif");
                ThumbnailHelper.CreateThumbnail(filePath,
                                                fc.GetAbsolutePublicCachePath(thumbnailFileName),
                                                new System.Drawing.Size(150, 100), false);

                return(fc.GetRelativePublicCachePath(thumbnailFileName));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        public async Task <bool> UpdateMapBBox(string mapID)
        {
            try
            {
                var list = _IMapReleationRepository.GetAll().Where(q => q.MapID == mapID).ToList();
                var map  = _IMapRepository.Get(mapID);
                if (map != null && list != null && list.Count > 0)
                {
                    Dictionary <string, decimal?> bbox = new Dictionary <string, decimal?>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        var layer = _ILayerContentRepository.Get(list[i].DataConfigID);

                        if (i == 0)
                        {
                            bbox.Add("MaxX", layer.MaxX);
                            bbox.Add("MinX", layer.MinX);
                            bbox.Add("MaxY", layer.MaxY);
                            bbox.Add("MinY", layer.MinY);
                        }
                        else
                        {
                            if (layer.MaxX > bbox["MaxX"])
                            {
                                bbox["MaxX"] = layer.MaxX;
                            }
                            if (layer.MaxY > bbox["MaxY"])
                            {
                                bbox["MaxY"] = layer.MaxY;
                            }
                            if (layer.MinX < bbox["MinX"])
                            {
                                bbox["MinX"] = layer.MinX;
                            }
                            if (layer.MinY < bbox["MinY"])
                            {
                                bbox["MinY"] = layer.MinY;
                            }
                        }
                    }
                    map.MaxX = bbox["MaxX"];
                    map.MinX = bbox["MinX"];
                    map.MaxY = bbox["MaxY"];
                    map.MinY = bbox["MinY"];

                    await _IMapRepository.UpdateAsync(map);


                    GeoServerHelper geoHelp     = new GeoServerHelper();
                    string          isAutoCache = ConfigurationManager.AppSettings.Get("IsAutoCache");
                    if (!string.IsNullOrEmpty(isAutoCache) && isAutoCache == "1")
                    {
                        geoHelp.TerminatingTask(map.MapEnName);
                        geoHelp.TileMap(map.MapEnName);
                    }

                    string strBBox = map.MinX.ToString() + "," + map.MinY.ToString() + "," + map.MaxX.ToString() + "," + map.MaxY.ToString();
                    #region [生成缩略图]

                    ThumbnailHelper tbh       = new ThumbnailHelper();
                    string          imagePath = tbh.CreateThumbnail(map.MapEnName, "map", strBBox);

                    if (string.IsNullOrEmpty(imagePath))
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }

                    #endregion
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }