How to load the images given by a query



Hi all,

I'm traying to develop an extension to find the photos no exported with any exporter extension. Actually i'v the result of the query executed by FSpot.Core.Database.Database.Query method i had try also with: photo_store.Query (String) bu it make this exception ("Input string was not in the correct format: nDigits == 0"), and with IQueryItems in a PhotoQuery but dont found a way to construct a complex query. So at the moment the query works. But how can i do this query the main query of the MainWindow.TopLevel? the query is this: "select id, uri from photos where id not in (select image_id from exports where export_type not like \"%"+export_type+"%\");" where export type should be one of the exporterplugins actives. The code i'm working on is attached, but its simply a lot of different tests to load the query in the main, window without luck. At the moment it opens a view window with all the pictures not uploaded to flickr. At the moment im developing the extension like a Tool so it ll be under the extensions/Tools/UnexportedFinder directory.
I sopose that there is an easy way to do it but can't find it, its my first code in c# and usually i program in topdown not oop

Sorry my poor english and i'll be very gracefull to have some orientation

bye guys
<Addin namespace="FSpot"
	id="UnexportedFinder"
	version="0.0.0.1"
	description="Search for pictures not exported for a given exporter extension"
	author="Abdul Pallare"
	url="http://f-spot.org/Extensions";
	name="Unexported Finder"
	category="Tools">
	<Dependencies>
		<Addin id="Core" version="0.5.0.0"/>
	</Dependencies>
	<Extension path = "/FSpot/Menus/Tools">
		<Command id = "FindUnexported" _label = "Search unexported" command_type = "UnexportedFinderExtension.UnexportedFinder" />
	</Extension>
</Addin>
//UnexportedFinder.cs
using Mono.Data.SqliteClient;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System;
using FSpot;
using FSpot.Extensions;
using FSpot.Query;
using Banshee.Database;

namespace UnexportedFinderExtension
{
	public class UnexportedFinder : ICommand
	{
		/*
		 * Conseguir un photolist o photoarray(IBrowsableItem[]) para tener un ibrowsablecollection y asi crear un
		 * photo_view (ya existe un PhotoView en Mainwindow.TopLevel pero no sirve hay que modificar la query de MainWindow
		 */
		
		
		ICore control;
		PhotoStore photo_store = new PhotoStore(FSpot.Core.Database.Database, false);
		//List<Photo> photos = new List<Photo> ();
		//PhotoArray photos;
		Photo []photos;
		UriCollection uris = new UriCollection();
		SqliteDataReader reader;
		//Photo []aa;
		Uri uri;
		UriList urilist = new UriList ();
		PhotoView photo_view;
		PhotoList files = new PhotoList(); //Implementa un IBrowsableItem
		//PhotoQuery pq = new PhotoQuery(photo_store);
		FileBrowsableItem file;
		
		private void GetUnexportedItems (string export_type)
		{
			
			try
			{
				reader = FSpot.Core.Database.Database.Query(new DbCommand("select id, uri from photos where id not in (select image_id from exports where export_type not like \"%:export_type%\");","export_type",export_type));
				
				//Console.WriteLine("sql: {0}",query.SqlClause());
				photos = photo_store.Query("select id, uri from photos where id not in (select image_id from exports where export_type not like \"%:"+export_type+"%\");");
				//photos = photo_store.Query("select id, uri from photos");
				while (reader.Read ()) {
					Console.WriteLine ("El id de la foto es: {0} el uri: "+reader["uri"],reader["id"]);
					//file = new FileBrowsableItem(new Uri(reader["uri"] as String));
					//files[files.Length] = file;
					//files.Add(new FileBrowsableItem(new Uri(reader["uri"] as String)));
					urilist.Add(new Uri(reader["uri"] as String));
				}
				Console.WriteLine("files: {0}",files);
			}catch (Exception e)
			{
				Console.WriteLine("Try 1:"+e.Message);				
			}				
				
			/*try
			{
				foreach (Photo photo in photos)
				{
					Console.WriteLine ("El id de la foto es: {0}",photo.Id);
					uris.Add(photo.DefaultVersionUri);
				}
			}catch (Exception e)
			{
				Console.WriteLine("Try 2:"+e.Message);
			}*/
			
			try
			{
				Console.WriteLine ("uri: {0}",uris);
			}catch (Exception e)
			{
				Console.WriteLine("Try 3:"+e.Message);
			}
			
			try
			{
				//aa = photos.ToArray();
				//foreach (Photo photo in photos)
				//         Console.WriteLine ("aaaaa "+photo.Time);
				//Console.WriteLine("photos: {0}",photos.Length);
				MainWindow.Toplevel.PhotoView.Query=files;
				MainWindow.Toplevel.UpdateQuery();
				Console.WriteLine ("MainQuery: {0}", MainWindow.Toplevel.Query.RollSet);
				//MainWindow.Toplevel.PhotoView.Reload();
				//MainWindow.Toplevel.PhotoView.Dispose();


				//Open a view class window with the unexported photos
				control = Core.FindInstance (); //find a reference to the main F-spot instance
				if (control == null) {
						Console.WriteLine ("Starting new FSpot server (f-spot {0})", FSpot.Defines.VERSION);
				} else
					Console.WriteLine ("Found active FSpot server: {0}", control);
				
				control.View (urilist.ToString ()); //This line open the window

				

				//reader.Close ();
			}catch (Exception e)
			{
				Console.WriteLine("Try 4:"+e.Message);
			}
		}
		
		public void Run (object o, EventArgs e)
		{
			GetUnexportedItems("flickr");
		}
	}
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]