Example #1
0
        /// <summary>
        /// 增加照片
        /// </summary>
        /// <param name="memberID"></param>
        /// <param name="photoType"></param>
        /// <param name="extName"></param>
        /// <param name="oFileName"></param>
        /// <param name="FileType"></param>
        /// <returns>照片ID</returns>
        public static Photo AddPhoto(String memberID, PhotoType photoType, String extName, String oFileName, String fileType, String newFileName)
        {
            try
            {
                //保存照片信息
                Photo myp = AddPhotoOrgin(memberID, photoType, extName, oFileName, fileType, newFileName);
                //用户照片类别为0-10
                if ((int)myp.PhotoType <= 10)
                {
                    //增加用户照片总数
                    MemberManager.MemberManager.ModifyPhotoCount(memberID, MemberManager.StatusModifyType.Add);

                    //增加动态
                    BiZ.Member.Activity.ActivityController.AddActivity(
                        memberID,
                        Member.Activity.ActivityType.UploadPhoto,
                        BiZ.Member.Activity.ActivityController.GetActivityContent_UploadPhoto_Title(),
                        BiZ.Member.Activity.ActivityController.GetActivityContent_UploadPhoto(newFileName),
                        false);
                }

                return myp;
            }
            catch (CBB.ExceptionHelper.OperationException err)
            {
                throw err;
            }
        }
Example #2
0
        /// <summary>
        /// Gets the image SRC.
        /// </summary>
        /// <returns></returns>
        public string GetImageSrc(Media media, PhotoType type)
        {
            MediaFile webSize = media.GetImageByPhotoType(type);
            string    url     = UrlService.CreateImageUrl(media.Owner.Username, webSize.FilePath);

            return(url);
        }
Example #3
0
 public AddPhotoView(computer selectedItem, PhotoType phototype)
 {
     InitializeComponent();
     this.selectedcomputer = selectedItem;
     this.photoType        = phototype;
     this.ChangePhoto();
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="filename"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int InsertPhoto(int id, string filename, PhotoType type)
        {
            string field = type == PhotoType.UserPhotos ? "User" : "Game";

            return(DalHelper.Insert($"INSERT INTO {type.ToString()} ({field}, Photo) VALUES ({id}, @filename)"
                                    , new OleDbParameter("@filename", filename)));
        }
        public PhotoGaleryCollection GetPhotoByType(PhotoType photoType)
        {
            var photoGalery = _sqlHelper.GetDataTable("select * from PhotoGalery where PhotoTypeId = " + (int)photoType);
            var photoGaleryCollection = new PhotoGaleryCollection();
            if (photoGalery.Rows.Count > 0)
            {
                for (int i = 0; i < photoGalery.Rows.Count; i++)
                {
                    var photo = new PhotoGalery
                    {
                        Description = photoGalery.Rows[i]["Description"].ToString(),
                        ImageUrl = photoGalery.Rows[i]["ImageUrl"].ToString(),
                        PhotoType = (PhotoType)photoGalery.Rows[i]["PhotoTypeId"],
                        Title = photoGalery.Rows[i]["Title"].ToString()
                    };

                    photoGaleryCollection.Add(photo);
                }
            }
            else
            {
                //TODO: Resim Yok
            }

            return photoGaleryCollection;
        }
Example #6
0
 public AddPhotoView(handphone selectedItem, PhotoType phototype)
 {
     InitializeComponent();
     this.selectedhandphone = selectedItem;
     this.photoType         = phototype;
     this.ChangePhoto();
 }
Example #7
0
 public static Photo GetPhotoByObjId(int objId, PhotoType type)
 {
     return(SQLDataAccess.ExecuteReadOne <Photo>("SELECT * FROM [Catalog].[Photo] WHERE [ObjId] = @ObjId and type=@type",
                                                 CommandType.Text, GetPhotoFromReader,
                                                 new SqlParameter("@ObjId", objId),
                                                 new SqlParameter("@type", type.ToString())));
 }
Example #8
0
 public static void DeletePhotoWithPath(PhotoType type, string photoName)
 {
     SQLDataAccess.ExecuteNonQuery("DELETE FROM [Catalog].[Photo] WHERE PhotoName = @PhotoName and type=@type",
                                   CommandType.Text,
                                   new SqlParameter("@PhotoName", photoName),
                                   new SqlParameter("@type", type.ToString()));
 }
 public bool GeneratePhoto(Guid guid, PhotoType photoType)
 {
     var file = String.Format("{0}/{1}-{2}.jpg", Folders.Photos, (byte)photoType, guid);
     if (_fileSystem.FileExists(file)) return true;
     var photo = GetPhoto(guid);
     return photo != null && GeneratePhoto2(photo, photoType);
 }
Example #10
0
        //---------------------------------------------
        static public PhotoList getBarberPhotos(string _barber_vk_id, PhotoType _photoType)
        {
            PhotoList photoList = new PhotoList();

            photoList.listType = _photoType;
            photoList.items    = new List <Photo>();
            SqlConnection connection = new SqlConnection(Options.MainOptions.ConnectionString);

            try
            {
                connection.Open();
                //string sqlExpression = "SELECT B.[BRA_ID], B.[BRA_NAME] FROM [WORKER_DOCTOR] DW, [WORKER_BRANCH] WB, [BRANCH] B WHERE DW.[DOCT_ID] = @DOCT_ID AND DW.[WORK_ID] = WB.[WORK_ID] AND WB.[BRA_ID] = B.[BRA_ID] AND DW.[MEDORG_ID] = @MEDORG_ID AND DW.[MEDORG_ID] = B.[MEDORG_ID] AND WB.[MEDORG_ID] = B.[MEDORG_ID] AND [TIME_PER_ID] IS NOT NULL GROUP BY B.[BRA_ID], B.[BRA_NAME] ";
                string sqlExpression =
                    @"select photo_id, Photo_Goal, Photo_VK_Link, Photo_Content, Photo_Comment
                            from photo p
                            where p.Bar_VK_ID = @BAR_VK_ID AND
	                            p.photo_goal = @PHOTO_TYPE"    ;
                SqlCommand command = new SqlCommand(sqlExpression, connection);
                command.Parameters.Add(new SqlParameter("BAR_VK_ID", _barber_vk_id));
                command.Parameters.Add(new SqlParameter("PHOTO_TYPE", (int)_photoType));
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Photo item = new Photo();
                        item.id   = reader.GetInt64(0);
                        item.type = (PhotoType)reader.GetInt16(1);
                        if (!reader.IsDBNull(2))
                        {
                            item.vk_link = reader.GetString(2);
                        }
                        if (!reader.IsDBNull(3))
                        {
                            item.content = reader.GetString(3);
                        }
                        if (!reader.IsDBNull(4))
                        {
                            item.comment = reader.GetString(4);
                        }
                        photoList.items.Add(item);
                    }
                }
                reader.Close();
                connection.Close();
            }
            catch (Exception e)
            {
                SendLogMessage(e.Message, System.Diagnostics.EventLogEntryType.Error, e);
                throw e;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(photoList);
        }
    /// <summary>
    /// 撮影チェック
    /// </summary>
    /// <param name="type"></param>
    /// <param name="playerSta"></param>
    /// <returns></returns>
    private bool CheckPhotoChance(PhotoType type, int playerSta)
    {
        var list = PhotoShotList[playerSta];

        // 既に撮影済みならスルー
        return(!(list[(int)type].isShootted));
    }
Example #12
0
        private FAdvancedCustom(
			List<CustomBurnInfo> alCustom,
			PhotoType photoType )
        {
            InitializeComponent();
            _alCustom = alCustom;
            _photoType = photoType;
        }
 public string GetPhotoUrl(Guid photoGuid, PhotoType photoType, bool encode = false)
 {
     if (encode) return GetUrl(String.Format("/{0}/{1}-{2}.jpg", ((photoGuid == Guid.Empty) ? Folders.Images : Folders.Photos), (byte) photoType, photoGuid));
     var path = String.Format("{0}/{1}/{2}-{3}.jpg", _baseFolderName, Folders.Photos, (byte) photoType, photoGuid);
     var bytes = File.ReadAllBytes(path);
     var base64 = Convert.ToBase64String(bytes);
     return base64;
 }
Example #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            PhotoType phototype = db.PhotoTypes.Find(id);

            db.PhotoTypes.Remove(phototype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #15
0
 public static void DeletePhotos(int objId, PhotoType type)
 {
     foreach (var photoName in GetNamePhotos(objId, type))
     {
         DeleteFile(type, photoName);
     }
     DeletePhotoByOwnerIdAndType(objId, type);
 }
Example #16
0
        public void WritePhoto(Photo photo, PhotoType photoType, byte[] bytes)
        {
            var path = String.Format("{0}/{1}/{2}-{3}.jpg", _baseFolderName, Folders.Photos, (byte)photoType, photo.Guid);

            using (var writer = new FileStream(path, FileMode.Create, FileAccess.Write)) {
                writer.Write(bytes, 0, bytes.Length);
            }
        }
Example #17
0
        public async Task <Photo> AddExternal(Photo photo, PhotoType type)
        {
            photo.CreatedBy   = UserId;
            photo.DateCreated = DateTime.UtcNow;
            photo.Type        = type;

            return(await _photoService.AddOrUpdatePhotoAsync(photo));
        }
Example #18
0
 public static void DeletePhotos(int objId, PhotoType type)
 {
     foreach (var photoName in GetNamePhotos(objId, type))
     {
         DeleteFile(type, photoName);
     }
     DeletePhotoByOwnerIdAndType(objId, type);
 }
Example #19
0
        /// <summary>
        /// return list of photos by type
        /// </summary>
        /// <param name="objId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IEnumerable <Photo> GetPhotos(int objId, PhotoType type)
        {
            var list = SQLDataAccess.ExecuteReadIEnumerable <Photo>("SELECT * FROM [Catalog].[Photo] WHERE [objId] = @objId and type=@type  ORDER BY [PhotoSortOrder]",
                                                                    CommandType.Text, GetPhotoFromReader,
                                                                    new SqlParameter("@objId", objId),
                                                                    new SqlParameter("@type", type.ToString()));

            return(list);
        }
Example #20
0
 public ActionResult Edit([Bind(Include = "ID,PhotoType1")] PhotoType phototype)
 {
     if (ModelState.IsValid)
     {
         db.Entry(phototype).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(phototype));
 }
Example #21
0
        /// <summary>
        /// 更新相册
        /// </summary>
        /// <param name="pType"></param>
        /// <returns></returns>
        public int UpdatePhotoType(PhotoType pType)
        {
            string sql = "update PhotoType set TypeName='" + pType.TypeName + "', TypeDes='" + pType.TypeDes + "' where TypeId=" + pType.TypeId;

            //SqlParameter[] param = {
            //    new SqlParameter("@TypeName",SqlDbType.NVarChar){Value=pType.TypeName },
            //    new SqlParameter("@TypeDes",SqlDbType.NVarChar){Value=pType.TypeDes }
            //};
            return(SQLHelper.ExecuteNonQuery(sql));
        }
Example #22
0
 public List <Photo> GetData(int id, PhotoType type)
 {
     using (var db = new OcphDbContext())
     {
         var Id  = id;
         var lap = type;
         var res = db.Photos.Where(O => O.ProductId == Id && O.ProductType == lap).ToList();
         return(res);
     }
 }
        //[AuthFilter]//身份认证,不带token或者token错误会被拦截器拦截进不来这个接口
        public IActionResult PhotoList(PhotoType photoType)
        {
            using EFCoreContextWrite context = new EFCore.EFCoreContextWrite();
            int total = 0;
            List <PictureListDto> PictureListDtos = new List <PictureListDto>();

            if (!PictureRedis.GetAll(out List <PictureInfo> Picture))
            {
                Picture = context.PictureInfo.Where(x => x.Disable == false).Include(x => x.Users).ToList();
                total   = Picture.Count();
                if (Picture != null && Picture.Count > 0)
                {
                    PictureRedis.SaveAll(Picture);
                }
                Picture = Picture.Where(x => x.Disable == false && x.PictureType == PictureType.Product && x.PhotoType == photoType).OrderByDescending(x => x.RecommendIndex).ToList();

                foreach (var item in Picture)
                {
                    PictureListDto PictureListDto = new PictureListDto()
                    {
                        ID             = item.Id,
                        CreateTime     = item.CreateTime,
                        Index          = item.RecommendIndex,
                        UserName       = item.Users.UserName,
                        PictureExplain = item.PictureExplain,
                        PictureTitle   = item.PictureTitle,
                        PictureUrl     = item.PictureContent,
                        PictureType    = item.PictureType
                    };
                    PictureListDtos.Add(PictureListDto);
                }
            }
            else
            {
                total   = Picture.Count();
                Picture = Picture.Where(x => x.Disable == false && x.PictureType == PictureType.Product && x.PhotoType == photoType).OrderByDescending(x => x.RecommendIndex).ToList();

                foreach (var item in Picture)
                {
                    PictureListDto PictureListDto = new PictureListDto()
                    {
                        ID             = item.Id,
                        CreateTime     = item.CreateTime,
                        Index          = item.RecommendIndex,
                        UserName       = item.Users.UserName,
                        PictureExplain = item.PictureExplain,
                        PictureTitle   = item.PictureTitle,
                        PictureUrl     = item.PictureContent,
                        PictureType    = item.PictureType
                    };
                    PictureListDtos.Add(PictureListDto);
                }
            }
            return(Ok(new ApiResponse(PictureListDtos, total)));
        }
        public byte[] GetPhoto(int id, PhotoType type)
        {
            switch (type)
            {
            case PhotoType.Thumbnail:
                return(_db.Photos.Find(id).PhotoFile.Thumbnail);

            default:
                return(_db.Photos.Find(id).PhotoFile.File);
            }
        }
Example #25
0
        public async Task <IEnumerable <Data.Shared.Models.Photo> > GetPhotosAsync(PhotoType type, int typeId)
        {
            var photoResult = _photoRepository.GetSomeAsync(p => p.Type == type.ToString() && p.TypeId == typeId);
            var photos      = new List <Data.Shared.Models.Photo>();

            await foreach (var photo in photoResult)
            {
                photos.Add(photo.AsModel(_blobStorageRoot));
            }
            return(photos);
        }
Example #26
0
        public ActionResult Create([Bind(Include = "ID,PhotoType1")] PhotoType phototype)
        {
            if (ModelState.IsValid)
            {
                db.PhotoTypes.Add(phototype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(phototype));
        }
Example #27
0
 public Photo AddPhoto(string filename, string comment, PhotoType type)
 {
     lock (Photos)
     {
         var p = new Photo(ObjectMode.New)
         {
             Vehicle = this, Filename = filename, Comment = comment, Type = type
         };
         Photos.Add(p);
         return(p);
     }
 }
Example #28
0
        public static Photo UploadFile(HttpPostedFileBase file, PhotoType photoType = PhotoType.AvatarImage)
        {
            var photo = new Photo();

            // Check if we have a file
            if (null == file)
            {
                return(photo);
            }
            // Make sure the file has content
            if (!(file.ContentLength > 0))
            {
                return(photo);
            }

            // escapse invalid charaters and %
            var encodedFileName = CleanFileName(file.FileName);

            string fileName = $"{Guid.NewGuid()}_{encodedFileName}";

            var fileExt = Path.GetExtension(file.FileName);

            // Issues happen when chinese charcters
            //fileName = Base64Coding.Encrption(fileName);
            //fileName += fileExt;

            // Make sure we were able to determine a proper extension
            if (null == fileExt)
            {
                return(photo);
            }

            // Check if the directory we are saving to exists
            if (!Directory.Exists(FilesPath))
            {
                // If it doesn't exist, create the directory
                Directory.CreateDirectory(FilesPath);
            }

            // Set our full path for saving
            string path = FilesPath + DirSeparator + fileName;

            // Save our file
            file.SaveAs(Path.GetFullPath(path));

            // Save our thumbnail as well
            var size = ResizeImage(file, fileName, Constants.Constants.DefaultResizeSize, Constants.Constants.DefaultResizeSize, photoType);

            photo.Name      = fileName;
            photo.PhotoSize = size;

            return(photo);
        }
Example #29
0
        public string GetPhotoUrl(Guid photoGuid, PhotoType photoType, bool encode = false)
        {
            if (encode)
            {
                return(GetUrl(String.Format("/{0}/{1}-{2}.jpg", ((photoGuid == Guid.Empty) ? Folders.Images : Folders.Photos), (byte)photoType, photoGuid)));
            }
            var path   = String.Format("{0}/{1}/{2}-{3}.jpg", _baseFolderName, Folders.Photos, (byte)photoType, photoGuid);
            var bytes  = File.ReadAllBytes(path);
            var base64 = Convert.ToBase64String(bytes);

            return(base64);
        }
Example #30
0
        /// <summary>
        /// Gets the type of the image by photo.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public MediaFile GetImageByPhotoType(PhotoType type)
        {
            MediaFile mediaFile = new MediaFile();

            foreach (MediaFile file in MediaFiles.Where(file => file.PhotoType == type))
            {
                mediaFile = file;
                break;
            }

            return(mediaFile);
        }
Example #31
0
        public bool GeneratePhoto(Guid guid, PhotoType photoType)
        {
            var file = String.Format("{0}/{1}-{2}.jpg", Folders.Photos, (byte)photoType, guid);

            if (_fileSystem.FileExists(file))
            {
                return(true);
            }
            var photo = GetPhoto(guid);

            return(photo != null && GeneratePhoto2(photo, photoType));
        }
Example #32
0
        /// <summary>
        /// 全屏时,w,h无效
        /// </summary>
        public HeroPhoto(ref RawImage image, int resId, PhotoType type, int w = 2048, int h = 2048, bool bFullScreen = false)
        {
            if (Application.isEditor)
            {
                image.material.shader = Shader.Find(image.material.shader.name);
            }
            Debug.Log("打开玩家展示:" + resId);
            m_bFullScreen = bFullScreen;
            if (bFullScreen)
            {
                RectTransform rect = image.GetComponent <RectTransform>();
                rect.anchorMax        = Vector2.one;
                rect.anchorMin        = Vector2.zero;
                rect.anchoredPosition = Vector2.zero;
                rect.sizeDelta        = Vector2.zero;
            }

            m_resId      = resId;
            m_photoImage = image;
            m_type       = type;
            m_w          = w;
            m_h          = h;

            UIHeroShowEffectCsv showEffectCsv = CsvManager.Inst.GetCsv <UIHeroShowEffectCsv>((int)eAllCSV.eAC_UIHeroShowEffect);

            m_showEffectData = showEffectCsv.GetData((int)m_resId);

            OnCreateEnv();

            if (type == PhotoType.uieffect)
            {
                OnCreateEnterPhoto("born");
            }
            else
            {
                // 先加载预加载再创建
                if (m_showEffectData == null)
                {
                    return;
                }
                LoadPre(m_showEffectData, () =>
                {
                    if (m_photoObject == null)
                    {
                        return;
                    }
                    OnCreateUI();
                    OnEnter();
                });
            }
            HeroPhotoMgr.Inst.Add(this);
        }
Example #33
0
        /// <summary>
        /// Gets the file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="mediaType">Type of the media.</param>
        /// <returns></returns>
        private MediaFile QueueFile(string fileName, PhotoType mediaType)
        {
            MediaFile mediaFile = new MediaFile
            {
                OriginalFileName = fileName,
                FileExtension    = Path.GetExtension(fileName),
                FilePath         = _mediaFilenameService.GetFilename(fileName, mediaType),
                PhotoType        = mediaType
            };

            mediaFile.MediaFormat = (mediaFile.FileExtension.Contains("fla") ? MediaFormat.Video : MediaFormat.Photo);
            return(mediaFile);
        }
        /// <summary>
        /// Gets the file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="mediaType">Type of the media.</param>
        /// <returns></returns>
        private MediaFile QueueFile(string fileName, PhotoType mediaType)
        {
            MediaFile mediaFile = new MediaFile
                                      {
                                          OriginalFileName = fileName,
                                          FileExtension = Path.GetExtension(fileName),
                                          FilePath = _mediaFilenameService.GetFilename(fileName, mediaType),
                                          PhotoType = mediaType
                                      };

            mediaFile.MediaFormat = (mediaFile.FileExtension.Contains("fla") ? MediaFormat.Video : MediaFormat.Photo);
            return mediaFile;
        }
        /// <summary>
        /// Gets the size.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        private Size GetSize(PhotoType type)
        {
            IEnumerable <Size> sizes = GetAllSizes();
            Size size = new Size();

            foreach (Size list in sizes.Where(list => list.PhotoType == type))
            {
                size = list;
                break;
            }

            return(size);
        }
Example #36
0
        /// <summary>
        /// return count of photos by type
        /// </summary>
        /// <param name="objId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int GetCountPhotos(int objId, PhotoType type)
        {
            if (objId == 0)
            {
                return(SQLDataAccess.ExecuteScalar <int>("SELECT Count(*) FROM [Catalog].[Photo] WHERE type=@type",
                                                         CommandType.Text, new SqlParameter("@type", type.ToString())));
            }

            var res = SQLDataAccess.ExecuteScalar <int>("SELECT Count(*) FROM [Catalog].[Photo] WHERE [objId] = @objId and type=@type",
                                                        CommandType.Text, new SqlParameter("@objId", objId), new SqlParameter("@type", type.ToString()));

            return(res);
        }
Example #37
0
 public int AddPhoto(PhotoType photoType)
 {
     string SQL = @"
     insert into Photos (picOrder,picType,status) values (10,@photoType,0);
     select SCOPE_IDENTITY() as picId;
     ";
     SqlParameter[] para = {
         new SqlParameter("@photoType", photoType)
     };
     object o = m_dao.ExecuteScalar(SQL, para);
     int id = Convert.ToInt32(o);
     return id;
 }
Example #38
0
        /// <summary>
        /// return list of filename to delete
        /// </summary>
        /// <param name="objId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IEnumerable <string> GetNamePhotos(int objId, PhotoType type)
        {
            if (objId == 0)
            {
                return(SQLDataAccess.ExecuteReadIEnumerable <string>("SELECT PhotoName FROM [Catalog].[Photo] WHERE type=@type",
                                                                     CommandType.Text, reader => SQLDataHelper.GetString(reader, "PhotoName"),
                                                                     new SqlParameter("@type", type.ToString())));
            }

            return(SQLDataAccess.ExecuteReadIEnumerable <string>("SELECT PhotoName FROM [Catalog].[Photo] WHERE [objId] = @objId and type=@type",
                                                                 CommandType.Text, reader => SQLDataHelper.GetString(reader, "PhotoName"),
                                                                 new SqlParameter("@objId", objId),
                                                                 new SqlParameter("@type", type.ToString())));
        }
        /// <summary>
        /// Saves the image.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public byte[] ResizeImage(byte[] image, PhotoType type)
        {
            byte[] resizeImage = image;

            if(type != PhotoType.Original)
            {
                Bitmap bitmap = image.ConvertByteArrayToBitmap();
                Size size = GetSize(type);

                Size imageSize = ImageSize(bitmap, size);
                resizeImage = image.Resize(imageSize.Width, imageSize.Height, ImageFormat.Jpeg);
            }

            return resizeImage;
        }
Example #40
0
        public static DialogResult showDialog(
			Form parent,
			List<CustomBurnInfo> alCustom,
			PhotoType photoType )
        {
            using (var dlg = new FAdvancedCustom(alCustom, photoType))
                if (dlg.ShowDialog(parent) == DialogResult.OK)
                {
                    alCustom.Clear();
                    alCustom.AddRange(from ListViewItem lvi in dlg.lv.Items select (CustomBurnInfo) lvi.Tag);
                    return DialogResult.OK;
                }
                else
                    return DialogResult.Cancel;
        }
        /// <summary>
        /// Retrieves the type of the by media.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="photoType">Type of the photo.</param>
        /// <returns></returns>
        private static MediaFile RetrieveByMediaType(Media media, PhotoType photoType)
        {
            MediaFile mediaFile = new MediaFile();

            foreach (MediaFile file in media.MediaFiles)
            {
                if (file.PhotoType == photoType)
                {
                    mediaFile = file;
                    break;
                }
            }

            return mediaFile;
        }
 private bool GeneratePhoto2(PhotoBackup photo, PhotoType photoType)
 {
     foreach (var suffix in PhotoTypes.Versions.Keys) {
         if ((byte)photoType != suffix) continue;
         byte[] bytes;
         using (var outputStream = new MemoryStream()) {
             using (var stream = new MemoryStream(photo.Data)) {
                 ImageBuilder.Current.Build(stream, outputStream, new ResizeSettings(PhotoTypes.Versions[suffix].ToString()), false, true);
                 bytes = outputStream.ToArray();
             }
         }
         using (var stream = new MemoryStream(bytes)) {
             _fileSystem.Add(String.Format("{0}/{1}-{2}.jpg", Folders.Photos, (byte)photoType, photo.Guid), stream);
         }
     }
     return true;
 }
Example #43
0
        public Photo Save(int id, int OwnerId, PhotoType PhotoType, string FilePath, string PreviewPath, string ThumbPath, string IconPath)
        {
            var photo = id > 0 ? GetById(id) : new Photo();

            photo.ArticleId = PhotoType == PhotoType.Article ? OwnerId : 0;
            photo.WorkId = PhotoType == PhotoType.Work ? OwnerId : 0;
            photo.PhotoType = (int)PhotoType;
            photo.FilePath = FilePath;
            photo.PreviewPath = PreviewPath;
            photo.ThumbPath = ThumbPath;
            photo.IconPath = IconPath;

            var photoDa = new PhotoDa(databasecontext);

            //if new
            if (id < 1) photo = photoDa.Add(photo);
            //update
            else photo = photoDa.Update(photo);

            return photo;
        }
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="cssClass">The CSS class.</param>
        /// <param name="set">The set.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static string GetImageDetailLinkForFirst(Media media, string cssClass, string set, PhotoType type)
        {
            IUserUrlService userUrlService = GetUserUrlService();
            Func<string, string> title =
                s => (string.IsNullOrEmpty(media.Title)
                     ? string.Empty
                     : string.Format("title=\"{0} - {1} {2}\"", media.Title, media.Owner.FirstName, media.Owner.LastName));

            MediaFile thumbnail = media.GetImageByPhotoType(type);
            const string linkFormat = "<a class=\"{5} lightbox\" name=\"{6}\"  href=\"{0}\" {1} ><img src=\"{2}\" alt=\"{3}\" {4} /></a>";
            string link = string.Format(linkFormat,
                userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId),
                title(media.Title),
                userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath),
                media.Title,
                title(media.Title),
                cssClass,
                media.MediaId);

            return link;
        }
Example #45
0
        public static string GetSimplePhotoUri(string p, PhotoType type)
        {
            JObject rawPhotoInfoText = JObject.Parse(p);
            var height = 96;
            var width = 96;
            var prefix = rawPhotoInfoText["prefix"] != null ? rawPhotoInfoText["prefix"].ToString().Replace("\"", "") : "";
            var suffix = rawPhotoInfoText["suffix"] != null ? rawPhotoInfoText["suffix"].ToString().Replace("\"", "") : "";

            switch (type) {
                case PhotoType.profile:
                    height = 96;
                    width = 96;
                    break;
                case PhotoType.venue:
                    height = rawPhotoInfoText["height"] != null ? int.Parse(rawPhotoInfoText["height"].ToString().Replace("\"", "")) : 100;
                    width = rawPhotoInfoText["width"] != null ? int.Parse(rawPhotoInfoText["width"].ToString().Replace("\"", "")) : 100;
                    break;
                default:
                    break;
            }

            return String.Format("{1}{2}x{3}{4}", prefix, height, width, suffix);
        }
Example #46
0
        public static IList<PhotoSimple> GetSimplePhotos(String memberID, PhotoType photoType, int pagesize, int pageno)
        {
            List<Photo> GetPhotos = new List<Photo>();

            MongoCursor<Photo> cur = MongoDBHelper.GetCursor<Photo>(
                    "Photos",
                    Query.And(Query.EQ("MemberID", memberID), Query.EQ("PhotoType", (int)photoType)),
                    new SortByDocument("CreatedTime", -1),
                    pageno,
                    pagesize);

            GetPhotos.AddRange(cur);

            List<PhotoSimple> ps = new List<PhotoSimple>();
            foreach (Photo myp in GetPhotos)
            {
                PhotoSimple mys = new PhotoSimple();
                mys.ID = myp.ID;
                mys.FileName = myp.FileName;
                ps.Add(mys);
            }

            return ps;
        }
Example #47
0
        public static IList<Photo> GetAuditPhotos(PhotoType photoType, int IsAudited, int pagesize, int pageno)
        {
            List<Photo> GetPhotos = new List<Photo>();

            MongoCursor<Photo> cur = MongoDBHelper.GetCursor<Photo>(
                   "Photos", Query.And(Query.EQ("IsAudited", IsAudited), Query.EQ("PhotoType", photoType)),
                   new SortByDocument("CreatedTime", -1), pageno, pagesize);
            //, Query.NE("PhotoType", PhotoType.RegisterPhoto)
            GetPhotos.AddRange(cur);

            return GetPhotos;
        }
Example #48
0
        /// <summary>
        /// return list of filename to delete
        /// </summary>
        /// <param name="objId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IEnumerable<string> GetNamePhotos(int objId, PhotoType type)
        {
            if (objId == 0)
                return SQLDataAccess.ExecuteReadIEnumerable<string>("SELECT PhotoName FROM [Catalog].[Photo] WHERE type=@type",
                                                                    CommandType.Text, reader => SQLDataHelper.GetString(reader, "PhotoName"),
                                                                    new SqlParameter("@type", type.ToString()));

            return SQLDataAccess.ExecuteReadIEnumerable<string>("SELECT PhotoName FROM [Catalog].[Photo] WHERE [objId] = @objId and type=@type",
                                                                    CommandType.Text, reader => SQLDataHelper.GetString(reader, "PhotoName"),
                                                                    new SqlParameter("@objId", objId),
                                                                    new SqlParameter("@type", type.ToString()));
        }
Example #49
0
        /// <summary>
        /// return count of photos by type
        /// </summary>
        /// <param name="objId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int GetCountPhotos(int objId, PhotoType type)
        {
            if (objId == 0)
                return SQLDataAccess.ExecuteScalar<int>("SELECT Count(*) FROM [Catalog].[Photo] WHERE type=@type",
                                                                  CommandType.Text, new SqlParameter("@type", type.ToString()));

            var res = SQLDataAccess.ExecuteScalar<int>("SELECT Count(*) FROM [Catalog].[Photo] WHERE [objId] = @objId and type=@type",
                                                                    CommandType.Text, new SqlParameter("@objId", objId), new SqlParameter("@type", type.ToString()));
            return res;
        }
Example #50
0
 public static Photo GetPhotoByObjId(int objId, PhotoType type)
 {
     return SQLDataAccess.ExecuteReadOne<Photo>("SELECT * FROM [Catalog].[Photo] WHERE [ObjId] = @ObjId and type=@type",
                                                 CommandType.Text, GetPhotoFromReader,
                                                 new SqlParameter("@ObjId", objId),
                                                 new SqlParameter("@type", type.ToString()));
 }
 /// <summary>
 /// Gets the image SRC.
 /// </summary>
 /// <returns></returns>
 public string GetImageSrc(Media media, PhotoType type)
 {
     MediaFile webSize = media.GetImageByPhotoType(type);
     string url = UrlService.CreateImageUrl(media.Owner.Username, webSize.FilePath);
     return url;
 }
        /// <summary>
        /// Gets the type of the image by photo.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public MediaFile GetImageByPhotoType(PhotoType type)
        {
            MediaFile mediaFile = new MediaFile();

            foreach (MediaFile file in MediaFiles.Where(file => file.PhotoType == type))
            {
                mediaFile = file;
                break;
            }

            return mediaFile;
        }
 /// <summary>
 /// Gets the filename.
 /// </summary>
 /// <param name="filename">The filename.</param>
 /// <param name="photoType">Type of the photo.</param>
 /// <returns></returns>
 public string GetFilename(string filename, PhotoType photoType)
 {
     string name = string.Format("{0}_{1}_{2}{3}", Path.GetFileNameWithoutExtension(filename), photoType, DateTime.UtcNow.Ticks, Path.GetExtension(filename));
     return name;
 }
Example #54
0
        public static Photo AddPhotoOrgin(String memberID, PhotoType photoType, String extName, String oFileName, String fileType, String newFileName)
        {
            try
            {
                Photo myf = new Photo();
                myf.MemberID = memberID;
                myf.PhotoType = photoType;
                myf.FileName = newFileName;
                myf.CreatedTime = DateTime.Now;

                MongoDatabase md = MongoDBHelper.MongoDB;
                MongoCollection<Photo> mc = md.GetCollection<Photo>("Photos");
                mc.Insert(myf);

                return myf;
            }
            catch (CBB.ExceptionHelper.OperationException err)
            {
                throw err;
            }
        }
Example #55
0
 /// <summary>
 /// return list of photos by type
 /// </summary>
 /// <param name="objId"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static IEnumerable<Photo> GetPhotos(int objId, PhotoType type)
 {
     var list = SQLDataAccess.ExecuteReadIEnumerable<Photo>("SELECT * FROM [Catalog].[Photo] WHERE [objId] = @objId and type=@type  ORDER BY [PhotoSortOrder]",
                                                             CommandType.Text, GetPhotoFromReader,
                                                             new SqlParameter("@objId", objId),
                                                             new SqlParameter("@type", type.ToString()));
     return list;
 }
Example #56
0
        public static IList<Photo> GetPhotos(String memberID, PhotoType photoType,int pagesize,int pageno)
        {
            List<Photo> GetPhotos = new List<Photo>();

            MongoCursor<Photo> cur = MongoDBHelper.GetCursor<Photo>(
                   "Photos",
                    Query.And(Query.EQ("MemberID", memberID), Query.EQ("PhotoType", (int)photoType)),
                   new SortByDocument("CreatedTime", -1),
                   pageno,
                   pagesize);

            GetPhotos.AddRange(cur);

            return GetPhotos;
        }
Example #57
0
 private static void DeletePhotoByOwnerIdAndType(int objId, PhotoType type)
 {
     SQLDataAccess.ExecuteNonQuery("Delete FROM [Catalog].[Photo] WHERE [ObjId] = @ObjId and type=@type", CommandType.Text,
                                     new SqlParameter("@objId", objId),
                                     new SqlParameter("@type", type.ToString()));
 }
Example #58
0
 private static void DeleteFile(PhotoType type, string photoName)
 {
     switch (type)
     {
         case PhotoType.Product:
             FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Original, photoName));
             FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photoName));
             FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photoName));
             FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName));
             FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photoName));
             break;
         case PhotoType.Brand:
             FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, photoName));
             break;
         case PhotoType.CategoryBig:
             FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photoName));
             break;
         case PhotoType.CategorySmall:
             FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photoName));
             break;
         case PhotoType.Carousel:
             FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.Carousel, photoName));
             break;
         case PhotoType.News:
             FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.News, photoName));
             break;
         case PhotoType.StaticPage:
             FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.StaticPage, photoName));
             break;
     }
 }
 public string AddPhotoLink(Guid showId, PhotoType type, string returnUrl)
 {
     return string.Format("/MyPhishMarket/AddPhoto.aspx?showId={0}&type={1}&returnUrl={2}", showId, (int)type, returnUrl);
 }
Example #60
0
 /// <summary>
 /// 按图片类别和审核状态获取多张图片
 /// </summary>
 /// <returns>图片总数</returns>
 public static long GetTypeAuditPhotoCount(PhotoType photoType, byte isAudited)
 {
     QueryComplete qc = null;
     try
     {
         qc = Query.And(
             Query.EQ("IsAudited", isAudited),
             Query.EQ("PhotoType", photoType)
             );
         MongoDatabase md = MongoDBHelper.MongoDB;
         int count = (int)MongoDBHelper.GetCount(Photo.GetCollectionName(), qc);
         return count;
     }
     catch (System.Exception err)
     {
         throw new CBB.ExceptionHelper.OperationException(
             CBB.ExceptionHelper.ErrType.SystemErr,
             CBB.ExceptionHelper.ErrNo.DBOperationError,
             err);
     }
 }