Could you please post the link to the beta version? I have searched every where and keep getting led into the gutter.
Assuming that the file format string is still the same as previous releases (AdId.ImageSize.FileType) you could slip in any missing code.
There is no point me giving you my code as its in C# unless your willing to take time to convert it to VB..
Have tried putting in break points and running the app in debug to see what it is actually doing? This way we can find where the code is letting you down..
Could you please post the link to the beta version?
A while back microsoft took the kit offline, not available for download.
And then they put it back up as the beta vesion,
however this new beta version won't work with the photos at all unless "Store in Database" is selected.
I have just been through the current starter kit and there is code to remove the images from the directory how ever there is only a trigger included in the "if site settings store in database", this does not make sense. The code is never triggered if the
option is to store photos in the directory..
After creating a listing I have also found that the id is always set to 0 for the images but when I rename to the ad id it works fine.
Im assuming you have a statement simular to this one..
public
static
void RemovePhotosByAdId(int adId)
{
SiteSettings s =
SiteSettings.GetSharedSettings();using
(PhotosDataAdapter db =
new
PhotosDataAdapter())
I see no reason for this not to work with out the Bold section of code. Give it a shot, other wise an else statement would be the next best step cause this is where the trigger stops in the deletion of photos and it never makes it to
private
static
bool DeleteLocalPhotoFiles(int adId)
Alright Ladies, Gentlemen, all of you in between.
I have now come up with a solution.
Note:
This problem only exist if you do NOT want your images in a database.
That you want them stored in a folder, such as Upload.
I ask that everyone with the classifieds starter kit, make these changes, and report any errors.
As far as I can tell, I tested everything that has to do with photos.
(Only on my local computer so far)
The file in question is App_Code/BLL/Photos.vb (Photos.cs for cSharp)
And there's two sections that get modified.
Do not just paste in, look for the sections, and then you can paste over them.
First the VB code:
Public
Shared
Sub RemovePhotosByAdId(ByVal adId
As
Integer)
Dim s
As SiteSettings = SiteSettings.GetSharedSettings()
Using db
As
New PhotosDataAdapter()
If s.StorePhotosInDatabase
Then
Dim photos
As AdsDataComponent.PhotosDataTable = db.GetPhotosByAdStatus(CInt(AdStatus.Deleted))
RemovePhotoFilesInTable(photos)
Else
Dim Photo
As AdsDataComponent.PhotosDataTable = GetPhotosByAdId(adId)
RemovePhotoFilesInTable(Photo)
End
If
End
Using
End
Sub
Private
Shared
Function DeleteLocalPhotoFiles(ByVal photoId
As
Integer)
As
Boolean
Dim result
As
Boolean =
False
Try
Dim fullPhotoPath
As
String = GetFilePath(photoId,
False, PhotoSize.Full)
Dim fullPhoto
As
String = fullPhotoPath.Replace("Admin",
"")
Dim mediumPhotoPath
As
String = GetFilePath(photoId,
False, PhotoSize.Medium)
Dim mediumPhoto
As
String = mediumPhotoPath.Replace("Admin",
"")
Dim smallPhotoPath
As
String = GetFilePath(photoId,
False, PhotoSize.Small)
Dim smallPhoto
As
String = smallPhotoPath.Replace("Admin",
"")
DeleteFile(fullPhoto)
DeleteFile(mediumPhoto)
DeleteFile(smallPhoto)
result =
True
Catch
End
Try
Return result
End
Function
Now the CS code:
Note:
I use a converter for cs, this is untested.
public static void RemovePhotosByAdId(int adId)
{
SiteSettings s = SiteSettings.GetSharedSettings();
using (PhotosDataAdapter db = new PhotosDataAdapter()) {
if (s.StorePhotosInDatabase) {
AdsDataComponent.PhotosDataTable photos = db.GetPhotosByAdStatus((int)AdStatus.Deleted);
RemovePhotoFilesInTable(photos);
}
else {
AdsDataComponent.PhotosDataTable Photo = GetPhotosByAdId(adId);
RemovePhotoFilesInTable(Photo);
}
}
Participant
1165 Points
1035 Posts
Has anyone made an update to remove photos?
Aug 06, 2008 12:13 AM|darkknight187|LINK
I just wanted to know if any one has made an upgrade for photo removeal.
If the ad is removed from database, it removes the column in the photosDB but not the actual images.
After a while that photos directory is going to be very large, with wasted space.
If anyone has already done this, would you mind sharing your code?
Thank you
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
Member
70 Points
102 Posts
Re: Has anyone made an update to remove photos?
Aug 06, 2008 04:01 AM|SpiderMaster|LINK
I Assume you are talking about the ftp directory? eg: www.YourSite.com/Uploads/
Participant
1165 Points
1035 Posts
Re: Has anyone made an update to remove photos?
Aug 06, 2008 10:19 AM|darkknight187|LINK
Yes, the actual images themselves.
It looks like the writers of the kit intended to get it to remove the actual photos,
as there is code that looks like it's supposed to in App_Code/BLL/Photos.vb
I guess it was never tested in the beta stages.
The only part of the kit that seems to remove all intances of the photos is managephotos.
And you have to remove them one by one.
Any thoughts, as to what is incorrect, why removeing from database, does not delete photos in upload directory as well?
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
Member
70 Points
102 Posts
Re: Has anyone made an update to remove photos?
Aug 06, 2008 10:55 AM|SpiderMaster|LINK
Could you please post the link to the beta version? I have searched every where and keep getting led into the gutter.
Assuming that the file format string is still the same as previous releases (AdId.ImageSize.FileType) you could slip in any missing code.
There is no point me giving you my code as its in C# unless your willing to take time to convert it to VB..
Have tried putting in break points and running the app in debug to see what it is actually doing? This way we can find where the code is letting you down..
Participant
1165 Points
1035 Posts
Re: Has anyone made an update to remove photos?
Aug 06, 2008 12:54 PM|darkknight187|LINK
A while back microsoft took the kit offline, not available for download.
And then they put it back up as the beta vesion,
however this new beta version won't work with the photos at all unless "Store in Database" is selected.
It was available at:
http://www.asp.net/downloads/starter-kits/classifieds/
But last I checked, a week ago, it was the above mentioned, damaged version.
If yours will remove from the directory, when you select remove from database,
from the MyAds.aspx page, I will convert it from c#.
I think the issue lies in App_Code/BLL/Photos.
Does yours work???
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
Member
70 Points
102 Posts
Re: Has anyone made an update to remove photos?
Aug 06, 2008 02:28 PM|SpiderMaster|LINK
I have just been through the current starter kit and there is code to remove the images from the directory how ever there is only a trigger included in the "if site settings store in database", this does not make sense. The code is never triggered if the option is to store photos in the directory..
After creating a listing I have also found that the id is always set to 0 for the images but when I rename to the ad id it works fine.
Im assuming you have a statement simular to this one..
public static void RemovePhotosByAdId(int adId){
SiteSettings s = SiteSettings.GetSharedSettings();using (PhotosDataAdapter db = new PhotosDataAdapter()){
if (s.StorePhotosInDatabase){
AdsDataComponent.PhotosDataTable photos = db.GetPhotosByAdStatus((int)AdStatus.Deleted);RemovePhotoFilesInTable(photos);
}
}
}
I see no reason for this not to work with out the Bold section of code. Give it a shot, other wise an else statement would be the next best step cause this is where the trigger stops in the deletion of photos and it never makes it to private static bool DeleteLocalPhotoFiles(int adId)
Participant
1165 Points
1035 Posts
Re: Has anyone made an update to remove photos?
Aug 06, 2008 06:11 PM|darkknight187|LINK
Alright, I'm taking a break.
I did make a little progress though.
Adding this else statement to the above.
Else
Dim Photo As AdsDataComponent.PhotosDataTable = GetPhotosByAdId(adId)RemovePhotoFilesInTable(Photo)
End IfDoes work, for the user in MyAds.aspx, but as Admin, checking remove from database, it doesn't work.
I'm going to have to cross check it later.
I'll keep everyone informed.
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.
Participant
1165 Points
1035 Posts
Re: Has anyone made an update to remove photos?
Aug 07, 2008 12:38 AM|darkknight187|LINK
Alright Ladies, Gentlemen, all of you in between.
I have now come up with a solution.
Note:
This problem only exist if you do NOT want your images in a database.
That you want them stored in a folder, such as Upload.
I ask that everyone with the classifieds starter kit, make these changes, and report any errors.
As far as I can tell, I tested everything that has to do with photos.
(Only on my local computer so far)
The file in question is App_Code/BLL/Photos.vb (Photos.cs for cSharp)
And there's two sections that get modified.
Do not just paste in, look for the sections, and then you can paste over them.
First the VB code:
Public Shared Sub RemovePhotosByAdId(ByVal adId As Integer) Dim s As SiteSettings = SiteSettings.GetSharedSettings() Using db As New PhotosDataAdapter() If s.StorePhotosInDatabase Then Dim photos As AdsDataComponent.PhotosDataTable = db.GetPhotosByAdStatus(CInt(AdStatus.Deleted))RemovePhotoFilesInTable(photos)
Else Dim Photo As AdsDataComponent.PhotosDataTable = GetPhotosByAdId(adId)RemovePhotoFilesInTable(Photo)
End If End Using End SubDeleteFile(fullPhoto)
DeleteFile(mediumPhoto)
DeleteFile(smallPhoto)
result =
True Catch End Try Return result End FunctionNow the CS code:
Note:
I use a converter for cs, this is untested.
public static void RemovePhotosByAdId(int adId)
{
SiteSettings s = SiteSettings.GetSharedSettings();
using (PhotosDataAdapter db = new PhotosDataAdapter()) {
if (s.StorePhotosInDatabase) {
AdsDataComponent.PhotosDataTable photos = db.GetPhotosByAdStatus((int)AdStatus.Deleted);
RemovePhotoFilesInTable(photos);
}
else {
AdsDataComponent.PhotosDataTable Photo = GetPhotosByAdId(adId);
RemovePhotoFilesInTable(Photo);
}
}
}
private static bool DeleteLocalPhotoFiles(int photoId)
{
bool result = false;
try {
string fullPhotoPath = GetFilePath(photoId, false, PhotoSize.Full);
string fullPhoto = fullPhotoPath.Replace("Admin", "");
string mediumPhotoPath = GetFilePath(photoId, false, PhotoSize.Medium);
string mediumPhoto = mediumPhotoPath.Replace("Admin", "");
string smallPhotoPath = GetFilePath(photoId, false, PhotoSize.Small);
string smallPhoto = smallPhotoPath.Replace("Admin", "");
DeleteFile(fullPhoto);
DeleteFile(mediumPhoto);
DeleteFile(smallPhoto);
result = true;
}
catch {
}
return result;
}
Please let me know if anyone comes across any errors.
Enjoy
Daniel
Please remember to mark the post as answer that solves your issue.
This will be greatly benificial for other users.