private void FindTitle()
        {
            NoteFilter filter = new NoteFilter();
            filter.Words = "intitle:\"EvernoteAPIからの検索テスト用ノート(画像あり)\"";

            int pageSize = 10;

            NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
            spec.IncludeTitle = true;

            NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

            WriteNoteList(notes);
        }
        public void Run()
        {
            int pageSize = 10;

            NoteFilter filter = new NoteFilter();
            filter.Order = (int)NoteSortOrder.UPDATED;

            NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
            spec.IncludeTitle = true;

            NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

            Console.WriteLine("最も直近に変更されたノートの検索");
            Console.WriteLine("該当件数:" + notes.TotalNotes);
            foreach (NoteMetadata note in notes.Notes)
            {
                Console.WriteLine(" * " + note.Title);
            }
        }
        public void Run()
        {
            int pageSize = 10;

            NoteFilter filter = new NoteFilter();
            filter.Words = "elephant";

            NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
            spec.IncludeTitle = true;

            NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

            Console.WriteLine("特定の単語を含むノートの検索");
            Console.WriteLine("該当件数:" + notes.TotalNotes);
            foreach (NoteMetadata note in notes.Notes)
            {
                Console.WriteLine(" * " + note.Title + ", " + note.Guid);
            }
        }
Ejemplo n.º 4
0
 public void send_findNotesMetadata(string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
 #endif
 {
   oprot_.WriteMessageBegin(new TMessage("findNotesMetadata", TMessageType.Call, seqid_));
   findNotesMetadata_args args = new findNotesMetadata_args();
   args.AuthenticationToken = authenticationToken;
   args.Filter = filter;
   args.Offset = offset;
   args.MaxNotes = maxNotes;
   args.ResultSpec = resultSpec;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   #if SILVERLIGHT || NETFX_CORE
   return oprot_.Transport.BeginFlush(callback, state);
   #else
   oprot_.Transport.Flush();
   #endif
 }
Ejemplo n.º 5
0
 public IAsyncResult send_findNotesMetadata(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
Ejemplo n.º 6
0
      public NotesMetadataList findNotesMetadata(string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
      {
        #if !SILVERLIGHT && !NETFX_CORE
        send_findNotesMetadata(authenticationToken, filter, offset, maxNotes, resultSpec);
        return recv_findNotesMetadata();

        #else
        var asyncResult = Begin_findNotesMetadata(null, null, authenticationToken, filter, offset, maxNotes, resultSpec);
        return End_findNotesMetadata(asyncResult);

        #endif
      }
Ejemplo n.º 7
0
 public IAsyncResult Begin_findNotesMetadata(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
 {
   return send_findNotesMetadata(callback, state, authenticationToken, filter, offset, maxNotes, resultSpec);
 }
Ejemplo n.º 8
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.String) {
           AuthenticationToken = iprot.ReadString();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Struct) {
           Filter = new NoteFilter();
           Filter.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 3:
         if (field.Type == TType.I32) {
           Offset = iprot.ReadI32();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 4:
         if (field.Type == TType.I32) {
           MaxNotes = iprot.ReadI32();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 5:
         if (field.Type == TType.Struct) {
           ResultSpec = new NotesMetadataResultSpec();
           ResultSpec.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
        public List<Note> FindNotes(string word, int pageSize)
        {
            try {
                NoteFilter filter = new NoteFilter();
                filter.Words = word;
                NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
                spec.IncludeTitle = true;

                NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

                List<Note> list = new List<Note>();
                foreach (NoteMetadata note in notes.Notes)
                {
                    // findNotesMetadataで取得するノートには、ノートの本文やリソースが含まれていないので個別に取得しなおす。
                    // 第4引数がtrueだとリソースを含んだノートが取得できる
                    // 第6引数はResourceAlternateData (位置情報など)の有無
                    Note fullNote = mNoteStore.getNote(mAuthToken, note.Guid,
                        true, true, false, false);
                    list.Add(fullNote);
                }

                return list;
            }
            catch (EDAMUserException ex)
            {
                throw new ApplicationException("Evernoteアクセスに失敗しました。"
                    + "ErrorCode=" + ex.ErrorCode
                    + ", Parameter=" + ex.Parameter
                    + ", EvernoteHost=" + mEvernoteHost,
                    ex);
            }
        }
Ejemplo n.º 10
0
 public NotesMetadataList findNotesMetadata(string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
 {
   send_findNotesMetadata(authenticationToken, filter, offset, maxNotes, resultSpec);
   return recv_findNotesMetadata();
 }
			internal List<NoteMetadata> FindNotesMetadata(NoteFilter filter, int maxResults, NotesMetadataResultSpec resultSpec)
			{
				return FindNotesMetadataInternal(filter, 0, resultSpec, maxResults, new List<NoteMetadata>());
			}
			///** Used to find the high-level information about a set of the notes from a user's account based on various criteria specified via a NoteFilter object.
			// This should be used instead of 'findNotes' whenever the client doesn't really need all of the deep structure of every Note and Resource, but just wants a high-level list of information. This will save time and bandwidth.
			// @param  filter The list of criteria that will constrain the notes to be returned.
			// @param  offset The numeric index of the first note to show within the sorted results. The numbering scheme starts with "0". This can be used for pagination.
			// @param  maxNotes The mximum notes to return in this query. The service will return a set of notes that is no larger than this number, but may return fewer notes if needed. The NoteList.totalNotes field in the return value will indicate whether there are more values available after the returned set.
			// @param  resultSpec This specifies which information should be returned for each matching Note. The fields on this structure can be used to eliminate data that the client doesn't need, which will reduce the time and bandwidth to receive and process the reply.
			// */
			public NotesMetadataList FindNotesMetadata(NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
			{
				return Client.findNotesMetadata(AuthenticationToken(), filter, offset, maxNotes, resultSpec);
			}
Ejemplo n.º 13
0
        public ISearchResults GetNotesMetaList(string searchString, NoteSortOrder sortOrder, bool ascending, int resultsPage, int pageSize)
        {
            NoteFilter noteFilter = new NoteFilter();
            noteFilter.Words = searchString;
            noteFilter.Order = (int)sortOrder;
            noteFilter.Ascending = ascending;

            NotesMetadataResultSpec resultsSpec = new NotesMetadataResultSpec();
            resultsSpec.IncludeTitle = true;
            resultsSpec.IncludeCreated = true;
            resultsSpec.IncludeNotebookGuid = true;
            resultsSpec.IncludeUpdated = true;
            resultsSpec.IncludeAttributes = true;
            resultsSpec.IncludeTagGuids = true;
            resultsSpec.IncludeContentLength = true;

            NotesMetadataList noteMetadataList;

            try {
                if (resultsPage < 1) resultsPage = 1;
                if (pageSize > 100) pageSize = 100;

                noteMetadataList = noteStore.findNotesMetadata(credentials.AuthToken, noteFilter, (resultsPage - 1) * pageSize, pageSize, resultsSpec);
            }
            catch (EDAMUserException)
            {
                throw new EvernoteServiceSDK1AuthorisationException();
            }

            List<ENNoteMetadataINoteMetadataAdapter> notesMetaWrapperList =
                noteMetadataList.Notes.ConvertAll(noteMeta => new ENNoteMetadataINoteMetadataAdapter(noteMeta));

            return new SearchResults() {
                        NotesMetadata = notesMetaWrapperList.ToList<INoteMetadata>(),
                        TotalResults = noteMetadataList.TotalNotes
                    };
        }
Ejemplo n.º 14
0
 public void send_findNotesMetadata(string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
 {
   oprot_.WriteMessageBegin(new TMessage("findNotesMetadata", TMessageType.Call, seqid_));
   findNotesMetadata_args args = new findNotesMetadata_args();
   args.AuthenticationToken = authenticationToken;
   args.Filter = filter;
   args.Offset = offset;
   args.MaxNotes = maxNotes;
   args.ResultSpec = resultSpec;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   oprot_.Transport.Flush();
 }
Ejemplo n.º 15
0
		public List<ENSessionFindNotesResult> FindNotes(ENNoteSearch noteSearch, ENNotebook notebook, SearchScope scope, SortOrder order, int maxResults)
		{
			if (!IsAuthenticated)
			{
				throw new ENAuthExpiredException();
			}

			// App notebook scope is internally just an "all" search, because we don't a priori know where the app
			// notebook is. There's some room for a fast path in this flow if we have a saved linked record to a
			// linked app notebook, but that case is likely rare enough to prevent complexifying this code for.
			if (scope.HasFlag(SearchScope.AppNotebook))
			{
				scope = SearchScope.All;
			}

			// Validate the scope and sort arguments.
			if (notebook != null && scope != SearchScope.None)
			{
				ENSDKLogger.ENSDKLogError("No search scope necessary if notebook provided.");
				scope = SearchScope.None;
			}
			else if (notebook == null && scope == SearchScope.None)
			{
				ENSDKLogger.ENSDKLogError("Search scope or notebook must be specified. Defaulting to personal scope.");
				scope = SearchScope.DefaultScope;
			}

			bool requiresLocalMerge = false;
			if (scope != SearchScope.None)
			{
				// Check for multiple scopes. Because linked scope can subsume multiple linked notebooks, that *always* triggers
				// the multiple scopes. If not, then both personal and business must be set together.
				if ((scope.HasFlag(SearchScope.Personal) && scope.HasFlag(SearchScope.Business)) || scope.HasFlag(SearchScope.PersonalLinked))
				{
					// If we're asked for multiple scopes, relevance is not longer supportable (since we
					// don't know how to combine relevance on the client), so default to updated date,
					// which is probably the closest proxy to relevance.
					if (order.HasFlag(SortOrder.Relevance))
					{
						ENSDKLogger.ENSDKLogError("Cannot sort by relevance across multiple search scopes. Using update date.");
						order = (EvernoteSDK.ENSession.SortOrder)EN_FLAG_CLEAR(order, SortOrder.Relevance);
						order = (EvernoteSDK.ENSession.SortOrder)EN_FLAG_SET(order, SortOrder.RecentlyUpdated);
					}
					requiresLocalMerge = true;
				}
			}

			NotesMetadataResultSpec resultSpec = new NotesMetadataResultSpec();
			resultSpec.IncludeNotebookGuid = true;
			resultSpec.IncludeTitle = true;
			resultSpec.IncludeCreated = true;
			resultSpec.IncludeUpdated = true;
			resultSpec.IncludeUpdateSequenceNum = true;

			NoteFilter noteFilter = new NoteFilter();
			noteFilter.Words = noteSearch.SearchString;

			if (order.HasFlag(SortOrder.Title))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.TITLE;
			}
			else if (order.HasFlag(SortOrder.RecentlyCreated))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.CREATED;
			}
			else if (order.HasFlag(SortOrder.RecentlyUpdated))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.UPDATED;
			}
			else if (order.HasFlag(SortOrder.Relevance))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.RELEVANCE;
			}

			// "Normal" sort is ascending for titles, and descending for dates and relevance.
			bool sortAscending = order.HasFlag(SortOrder.Title) ? true : false;
			if (order.HasFlag(SortOrder.Reverse))
			{
				sortAscending = !sortAscending;
			}
			noteFilter.Ascending = sortAscending;

			if (notebook != null)
			{
				noteFilter.NotebookGuid = notebook.Guid;
			}

			// Set up context
			ENSessionFindNotesContext context = new ENSessionFindNotesContext();
			context.scopeNotebook = notebook;
			context.scope = scope;
			context.order = order;
			context.noteFilter = noteFilter;
			context.resultSpec = resultSpec;
			context.maxResults = maxResults;
			context.findMetadataResults = new List<NoteMetadata>();
			context.requiresLocalMerge = requiresLocalMerge;
			context.sortAscending = sortAscending;

			// If we have a scope notebook, we already know what notebook the results will appear in.
			// If we don't have a scope notebook, then we need to query for all the notebooks to determine
			// where to search.
			if (context.scopeNotebook == null)
			{
				context = FindNotes_ListNotebooks(context);
				return context.results;
			}

			context = FindNotes_FindInPersonalScope(context);
			return context.results;
		}
			internal List<NoteMetadata> FindNotesMetadataInternal(NoteFilter filter, int offset, NotesMetadataResultSpec resultSpec, int maxResults, List<NoteMetadata> results)
			{
				// If we've already fulfilled a bounded find order, then we are done.
				if (maxResults > 0 && results.Count >= maxResults)
				{
					return results;
				}

				// For this call, ask for the remaining number to fulfill the order, but don't exceed standard max.
				int maxNotesThisCall = FIND_NOTES_DEFAULT_MAX_NOTES;
				if (maxResults > 0)
				{
					maxNotesThisCall = Math.Min(maxResults - results.Count, maxNotesThisCall);
				}

				try
				{
					NotesMetadataList metadata = FindNotesMetadata(filter, offset, maxNotesThisCall, resultSpec);
					// Add these results.
					results.AddRange(metadata.Notes);
					// Did we reach the total? (Use this formulation instead of checking against the results array length
					// because in theory the note count total could change between calls.
					int nextIndex = metadata.StartIndex + metadata.Notes.Count;
					int remainingCount = metadata.TotalNotes - nextIndex;
					// Go for another round if there are more to get.
					if (remainingCount > 0)
					{
						results = FindNotesMetadataInternal(filter, nextIndex, resultSpec, maxResults, results);
						return results;
					}
					else
					{
						// Done.
						return results;
					}
				}
                catch (Evernote.EDAM.Error.EDAMNotFoundException)
                {
                    // Failed to get the sharedNotebook from the service.
                    // The shared notebook could be deleted from the owner.
                    ENSDKLogger.ENSDKLogError("EDAMNotFound error in FindNotesMetadata - shared notebook not found");
                    return null;
                }
				catch (Exception ex)
				{
					throw new Exception(ex.Message, ex.InnerException);
				}
			}
Ejemplo n.º 17
0
        private void launch(BackgroundWorker worker, DoWorkEventArgs e)
        {
            //this.pbProgress.Value = 0;
            //SetProgress(0);
            //frmMain frmMainE = (frmMain)e.Argument;
            myParams = (Parameters)e.Argument;
            ProgressStatusClass myProgress = new ProgressStatusClass();

            // List of listed extensions when Only Music Files is Checked
            List<string> sExtOK = new List<string>();
            sExtOK.Add(".flac");
            sExtOK.Add(".mp3");
            sExtOK.Add(".ogg");
            sExtOK.Add(".wma");
            sExtOK.Add(".alac");

            foreach (Notebook notebook in notebooks)
            {
                if (notebook.Name == myParams.Notebook)
                {
                    musicNotebook = notebook;
                }
            }

            // Liste des M-0Top
            if (chkRegenLists.Checked)
            {
                //TextWriter tw_lst = new StreamWriter(myParams.Folder + "\\camuma-top.lst", false, Encoding.Default);
                TextWriter tw_lst = new StreamWriter(myParams.Folder + "\\camuma-top.lst", false, Encoding.GetEncoding(850));

                NoteFilter filter = new NoteFilter();
                filter.NotebookGuid = musicNotebook.Guid;
                //filter.Words = "intitle:\"" + dir.Name + "\"";
                //any: "Camuma ID: 153266"  intitle:"Muse - 1999 - Showbiz"
                //filter.Words = "\"CaMuMa ID: " + sId + "\"";
                // Recherche par CaMuMa ID ou Titre
                //filter.Words = "any: \"CaMuMa ID: " + sId + "\" intitle:\"" + dir.Name + "\"";
                filter.Words = "tag:M-0Top";
                NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
                spec.IncludeTitle = true;
                int pageSize = 10;
                int offset = 0;
                NotesMetadataList notes = noteStore.findNotesMetadata(authToken, filter, 0, pageSize, spec);
                do {
                    notes = noteStore.findNotesMetadata(authToken, filter, offset, pageSize, spec);
                    foreach (NoteMetadata note in notes.Notes) {
                        Console.WriteLine("M-0Top : " + note.Title);
                        tw_lst.WriteLine(note.Title);
                    }
                    offset = offset + notes.Notes.Count;
                } while (notes.TotalNotes > offset);
                tw_lst.Close();
            } //Liste des M-0Top

            /*if (chkPdf.Checked)
            {
                PdfDocument pdf = new PdfDocument();
                pdf.PageLayout = PdfPageLayout.TwoColumnLeft;
                //pdf.PageMode = PdfPageMode.
                pdf.Info.Title = "CaMuMa List";
                //pdf.Info.Producer = "Calexo CaMuMa";
                pdf.Info.Creator = "Calexo CaMuMa";
            }*/

            // Listing all directories
            DirectoryInfo dir = new DirectoryInfo(myParams.Folder);
            DirectoryInfo dir2;
            //String sMsg="";
            Int32 i = 0;
            foreach (DirectoryInfo f in dir.GetDirectories())
            {
                this.sFolderList[i] = f.FullName;
                dir2 = new DirectoryInfo(this.sFolderList[i]);
                foreach (DirectoryInfo f2 in dir2.GetDirectories())
                {
                    i++;
                    this.sFolderList[i] = f2.FullName;
                }

                i++;
                myProgress.Info = i + " directories...";
                worker.ReportProgress(0, myProgress);
            }

            //TextWriter tw = new StreamWriter(myParams.Folder + "\\camuma.lst", false, System.Text.Encoding.Unicode);
            //TextWriter tw = new StreamWriter(myParams.Folder + "\\camuma.lst", false, Encoding.GetEncoding(65001));
            //TextWriter tw = new StreamWriter(myParams.Folder + "\\camuma.lst", false, Encoding.BigEndianUnicode);
            TextWriter tw = new StreamWriter(myParams.Folder + "\\camuma.lst", false, Encoding.Default);

            // Checking each directory
            // Checking if MP3 or Flac is here
            // Adding note
            bool isFlac, isMP3, isAlac, isWma;
            bool isFolderJPG;
            bool isSpotify;
            String sFileList;
            String sContent = "";
            String sFolderJPG = "";
            Int32 j = 0;
            String sId = "";
            List<string> lTagNames;
            String sArtist, sAlbum, sYear; //, sGenre;
            Boolean isParsed;
            Regex oRegex; MatchCollection oMatchCollection;

            String regArtist = @"^(?<ARTIST>([\w\'\(\)\&\, -])*([\w\'\(\)\&\,]))";
            String regAlbum = @"(?<ALBUM>([\w\'\(\)\-\&\,\. ])+)$";
            String regYear = @"(?<YEAR>([0-9]{4}))";
            String regDash = "[ ]+-[ ]+";

            foreach (String sDirName in sFolderList)
            {
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                if (sDirName != null)
                {
                    dir = new DirectoryInfo(sDirName);
                    isFlac = false;
                    isMP3 = false;
                    isWma = false;
                    isAlac = false;
                    isSpotify = false;
                    isFolderJPG = false;
                    sFolderJPG = "";
                    sFileList = "<div ><ul>";// "<div><b>" + WebUtility.HtmlEncode("Liste des fichiers :") + "</b></div>";
                    sContent = "";
                    sArtist = ""; sAlbum = ""; sYear = ""; //sGenre = "";
                    isParsed = false;

                    if (chkAddIdTags.Checked)
                    {
                        if (File.Exists(dir.FullName + "\\camuma.id"))
                        {
                            TextReader tr = new StreamReader(dir.FullName + "\\camuma.id");
                            sId = tr.ReadLine().Trim();
                        }
                        else
                        {
                            Random rRnd = new Random();
                            int iRnd = rRnd.Next(1001, 999999);
                            sId = iRnd.ToString().PadLeft(6,'0');
                            System.IO.File.WriteAllText(@dir.FullName + "\\camuma.id", sId);
                        }

                        // Ajout au camuma.lst
                        tw.WriteLine(sId + ":" + dir.FullName.Replace(myParams.Folder+"\\",""));
                        //tw.Flush();

                        if (!File.Exists(dir.FullName + "\\camuma.png"))
                        {
                            QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.M);
                            QrCode qrCode = new QrCode();
                            //QrCode qrCode = qrEncoder.Encode(sId, out qrCode);
                            qrEncoder.TryEncode("camuma://" + sId, out qrCode);
                            //GraphicsRenderer renderer = new GraphicsRenderer(5, Brushes.Black, Brushes.White);
                            GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Zero), Brushes.Black, Brushes.White);
                            //int pixelSize = renderer.Measure( qrCode.Matrix.Width).Width;
                            //WriteableBitmap wBitmap = new WriteableBitmap(pixelSize, pixelSize, 96, 96, PixelFormats.Gray8, null);
                            //renderer.CreateImageFile(qrCode.Matrix, @dir.FullName + "\\camuma.png", ImageFormat.Png);

                            using (FileStream stream = new FileStream(@dir.FullName + "\\camuma.png", FileMode.Create))
                            {
                                renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, stream);
                            }

                            SizeF size;
                            Font f = new Font(FontFamily.GenericSansSerif,20);
                            // creates 1Kx1K image buffer and uses it to find out how bit the image needs to be to fit the text
                            using (Image imageg = (Image)new Bitmap(1000, 1000))
                                size = Graphics.FromImage(imageg).MeasureString(sId, f);

                            using (Bitmap image = new Bitmap((int)size.Width, (int)size.Height)) //,, PixelFormat.Format32bppArgb))
                            {
                                Graphics g = Graphics.FromImage((Image)image);
                                //g.TranslateTransform(image.Width, image.Height);
                                //g.RotateTransform(180.0F); //note that we need the rotation as the default is down
                                //Color colBG = new Color();
                                //colBG.
                                g.Clear(ColorTranslator.FromHtml("#ABDA4C"));
                                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                                // draw text
                                g.DrawString(sId, f, Brushes.Black, 0f, 0f);

                                //note that this image has to be a PNG, as GDI+'s gif handling renders any transparency as black.
                                //context.Response.AddHeader("ContentType", "image/png");
                                using (MemoryStream memStream = new MemoryStream())
                                {
                                    //note that context.Response.OutputStream doesn't support the Save, but does support WriteTo
                                    image.Save(memStream, ImageFormat.Png);
                                    //memStream.WriteTo(context.Response.OutputStream);
                                    System.IO.File.WriteAllBytes(@dir.FullName + "\\camumaid.png", memStream.ToArray());
                                }
                            }

                        }
                    }

                    foreach (FileInfo f in dir.GetFiles())
                    {
                        //if (f.Extension.Equals("flac", StringComparison.CurrentCultureIgnoreCase)
                        if (f.Extension.Equals(".flac", StringComparison.CurrentCultureIgnoreCase)) isFlac = true;
                        else if (f.Extension.Equals(".mp3", StringComparison.CurrentCultureIgnoreCase)) isMP3 = true;
                        else if (f.Extension.Equals(".wma", StringComparison.CurrentCultureIgnoreCase)) isWma = true;
                        else if (f.Extension.Equals(".alac", StringComparison.CurrentCultureIgnoreCase)) isAlac = true;
                        else if (f.Name.Equals("folder.jpg", StringComparison.CurrentCultureIgnoreCase))
                        {
                            isFolderJPG = true;
                            sFolderJPG = f.FullName;
                        }
                        if (!chkMusicFiles.Checked || sExtOK.Contains(f.Extension.ToLower()))
                        {
                            sFileList += "<li>" + WebUtility.HtmlEncode(f.Name) + "</li>";
                        }
                    }
                    sContent = "<h1>" + WebUtility.HtmlEncode(dir.Name) + "</h1>";
                    sContent += sFileList + "</ul></div>";

                    if (isMP3 || isFlac || isWma || isAlac)
                    {
                        j++;
                        myProgress.ProgressValue = j;
                        myProgress.Info = j + "/" + i +" \nAlbum...";
                        worker.ReportProgress(j, myProgress);
                        //Info("Creating Note... " + j + "/" + i);

                        lTagNames = new List<string>();
                        lTagNames.Add("M-Support:Cowon");
                        lTagNames.Add("M-Support:NAS2");
                        lTagNames.Add("M-Support:WD");
                        lTagNames.Add("M-Album");
                        if (isMP3) lTagNames.Add("M-MP3");
                        if (isFlac) lTagNames.Add("M-FLAC");
                        if (isAlac) lTagNames.Add("M-ALAC");
                        if (isWma) lTagNames.Add("M-WMA");
                        if (isFolderJPG) lTagNames.Add("M-Cover");
                        else lTagNames.Add("M-NoCover");

                        Console.WriteLine(dir.Name + "...");

                        // ARTIST - YEAR - ALBUM
                        oRegex = new Regex(regArtist + regDash + regYear + regDash + regAlbum);
                        oMatchCollection = oRegex.Matches(dir.Name);
                        foreach (Match oMatch in oMatchCollection)
                        {
                            Console.WriteLine(" * " + oMatch.Groups["ARTIST"] + ":" + oMatch.Groups["ALBUM"] + "(" + oMatch.Groups["YEAR"] + ")");
                            sArtist = oMatch.Groups["ARTIST"].ToString();
                            sYear = oMatch.Groups["YEAR"].ToString();
                            sAlbum = oMatch.Groups["ALBUM"].ToString();
                            isParsed = true;
                        }

                        // ARTIST - ALBUM - YEAR
                        if (!isParsed)
                        {
                            oRegex = new Regex(regArtist + regDash + regAlbum + regDash + regYear);
                            oMatchCollection = oRegex.Matches(dir.Name);
                            foreach (Match oMatch in oMatchCollection)
                            {
                                Console.WriteLine(" * " + oMatch.Groups["ARTIST"] + ":" + oMatch.Groups["ALBUM"] + "(" + oMatch.Groups["YEAR"] + ")");
                                sArtist = oMatch.Groups["ARTIST"].ToString();
                                sYear = oMatch.Groups["YEAR"].ToString();
                                sAlbum = oMatch.Groups["ALBUM"].ToString();
                                isParsed = true;
                            }
                        }

                        // ARTIST - ALBUM
                        if (!isParsed)
                        {
                            oRegex = new Regex(regArtist + regDash + regAlbum);
                            oMatchCollection = oRegex.Matches(dir.Name);
                            foreach (Match oMatch in oMatchCollection)
                            {
                                //lTagNames.Add (oMatch.Groups["ARTIST"].ToString());
                                Console.WriteLine(" * " + oMatch.Groups["ARTIST"] + ":" + oMatch.Groups["ALBUM"]);
                                sArtist = oMatch.Groups["ARTIST"].ToString();
                                sAlbum = oMatch.Groups["ALBUM"].ToString();
                                isParsed = true;
                            }
                        }

                        if (isParsed)
                        {
                            sArtist = sArtist.Trim();
                            sYear = sYear.Trim();
                            sAlbum = sAlbum.Trim();
                            if (!String.IsNullOrWhiteSpace(sArtist)) lTagNames.Add("M-Artist:" + sArtist);
                            if (!String.IsNullOrWhiteSpace(sYear)) lTagNames.Add("M-Year:" + sYear);
                            else lTagNames.Add("M-Year:None");
                            //if (!String.IsNullOrWhiteSpace(sAlbum)) lTagNames.Add("M-Album:" + sAlbum);

                            myProgress.Info = j + "/" + i + "\n"  + "Album : " + sArtist + ":" + sAlbum + "... ";
                            worker.ReportProgress(j, myProgress);
                        }
                        else lTagNames.Add("M-NotParsed");

                        // Spotify
                        if (chkSpotify.Checked)
                        {
                            try
                            {
                                SearchResults<Album> spoRes = Search.SearchAlbums(dir.Name);
                                if (spoRes.SearchResultsPage.Length > 0)
                                {
                                    Album album = spoRes.SearchResultsPage.First();
                                    Console.WriteLine(" * Spotify : " + album.Artist + " - " + album.Name + " (" + album.Url + ")");
                                    sContent += "<div><br/></div>";
                                    sContent += "<h2>Liens</h2>";
                                    sContent += "<div><strong>Spotify</strong> : ";
                                    sContent += "<a href=\"" + album.Url + "\">";
                                    sContent += WebUtility.HtmlEncode(album.Artist + " - " + album.Name + " : " + album.Url);
                                    sContent += "</a>";
                                    sContent += "</div>";

                                    lTagNames.Add("M-Spotify");
                                    isSpotify = true;
                                }
                            }
                            catch (WebException we)
                            {
                                Console.WriteLine(" * Spotify : " + we.Message);
                            }
                            catch (System.FormatException we)
                            {
                                Console.WriteLine(" * Spotify : " + we.Message);
                            }
                        } // chkSpotify true

                        /*foreach (Album album in spoRes.SearchResultsPage)
                        {
                            Console.WriteLine(" * Spotify : " + album.Artist + " - " + album.Name + " (" + album.Url + ")");
                        }*/

                        // Add CaMuMa Id
                        sContent += "<div><p><i>CaMuMa ID:</i> <a href=\"camuma://" + sId + "\">" + sId + "</a></p>";
                        byte[] image = ReadFully(File.OpenRead(@dir.FullName + "\\camuma.png"));
                        byte[] hashQR = new MD5CryptoServiceProvider().ComputeHash(image);
                        String hashHexQR = BitConverter.ToString(hashQR).Replace("-", "").ToLower();
                        //sContent += "<a href=\"camuma://" + sId + "\">";
                        sContent += "<en-media type=\"image/png\" hash=\"" + hashHexQR + "\"/>";
                        sContent += "</div>";
                        Data data = new Data();
                        data.Size = image.Length;
                        data.BodyHash = hashQR;
                        data.Body = image;
                        Resource imgQR = new Resource();
                        imgQR.Mime = "image/png";
                        imgQR.Data = data;
                        Console.WriteLine(@dir.FullName + "\\camuma.png -> " + hashHexQR);

                        // On ajoute si on n'est pas dans le Action AddSpotify
                        // ou si il y a effectivement du Spotify
                        if (chkEvernote.Checked)
                        {
                            if (!rbActSpotify.Checked || isSpotify)
                            {
                                // On recherche la note avec le même titre
                                NoteFilter filter = new NoteFilter();
                                filter.NotebookGuid = musicNotebook.Guid;
                                //filter.Words = "intitle:\"" + dir.Name + "\"";
                                //any: "Camuma ID: 153266"  intitle:"Muse - 1999 - Showbiz"
                                //filter.Words = "\"CaMuMa ID: " + sId + "\"";
                                // Recherche par CaMuMa ID ou Titre
                                //filter.Words = "any: \"CaMuMa ID: " + sId + "\" intitle:\"" + dir.Name + "\"";
                                filter.Words = "\"CaMuMa ID: " + sId;
                                NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
                                spec.IncludeTitle = true;
                                int pageSize = 10;
                                NotesMetadataList notes = noteStore.findNotesMetadata(authToken, filter, 0, pageSize, spec);

                                // Non existing Note
                                if (notes.TotalNotes == 0)
                                {
                                    // If Adding ou Replacing
                                    if (rbAdd.Checked || rbReplace.Checked)
                                    {
                                        // Creating new note
                                        createNote(sFolderJPG, sContent, dir.Name, lTagNames, imgQR);
                                        Console.WriteLine(" * Creation");
                                    }
                                }
                                else if (notes.TotalNotes == 1)
                                {
                                    NoteMetadata noteToMod = notes.Notes.First();
                                    Console.WriteLine(" * Existing...");
                                    if (rbReplace.Checked)
                                    {
                                        Note note = noteStore.getNote(authToken, noteToMod.Guid, true, true, false, false);
                                        String hashHex = "";

                                        // Suppr tags négatifs (NotParsed, ...)
                                        note.TagGuids.Remove(getTagGuid("M-NotParsed"));
                                        note.TagGuids.Remove(getTagGuid("M-NoCover"));
                                        // Adding new tags
                                        note.TagNames = lTagNames;
                                        byte[] hash = null;
                                        if (sFolderJPG != "")
                                        {
                                            Console.WriteLine(" * folder.jpg exists");
                                            image = ReadFully(File.OpenRead(sFolderJPG));
                                            hash = new MD5CryptoServiceProvider().ComputeHash(image);
                                            hashHex = BitConverter.ToString(hash).Replace("-", "").ToLower();
                                        }

                                        if (note.Content != nodeContentEnrich(sContent, hashHex))
                                        {
                                            Console.WriteLine(" * Different contents");
                                            note.Content = nodeContentEnrich(sContent, hashHex);
                                            note.Resources = new List<Resource>();

                                            if (hash != null)
                                            {
                                                Console.WriteLine(" * Adding folder image");
                                                Data dataF = new Data();
                                                dataF.Size = image.Length;
                                                dataF.BodyHash = hash;
                                                dataF.Body = image;
                                                Resource resource = new Resource();
                                                resource.Mime = "image/jpg";
                                                resource.Data = dataF;
                                                note.Resources.Add(resource);
                                            }

                                            note.Resources.Add(imgQR);

                                            Console.WriteLine("Res : " + note.Resources.Count);

                                            note.UpdateSequenceNum = 0;
                                            note.Updated = 0;

                                            Note newNote = noteStore.updateNote(authToken, note);

                                            if (newNote != null)
                                            {
                                                Console.WriteLine(" * Modified");
                                                Console.WriteLine("Res : " + newNote.Resources.Count);
                                                //Console.WriteLine(newNote.Title);
                                                //Console.WriteLine(newNote.Updated);
                                                //Console.WriteLine(note.UpdateSequenceNum + " -> " + newNote.UpdateSequenceNum);
                                            }
                                            else
                                            {
                                                Console.WriteLine(" * Modification failed");
                                            }
                                        }

                                    }
                                } // TotalNotes=1
                                else // More than 1 matches
                                {
                                    createNote(sFolderJPG, sContent, dir.Name, lTagNames, imgQR);
                                    Console.WriteLine(" * ERROR - Multiple found");
                                }
                            } // ActSpotify
                        } // chkEvernote
                    }
                    else
                    {
                        i--;
                    }
                }

                //this.pbProgress.Maximum = i;
                //pbProgress.Value = j;

                myProgress.ProgressMax = i;
                myProgress.ProgressValue = j;
                worker.ReportProgress(j, myProgress);
            }
            //Info("OK");
            tw.Close();
        }