• Tabbles.net       
  • Chat |
  • Blog |
  • Wiki |
  • Move files with Tabbles instead of Explorer

    F#, C#, WPF and more.
    This is the place to discuss the technology behind Tabbles.

    Re: Move files with Tabbles instead of Explorer

    Postby Leandro » Fri Jul 30, 2010 10:48 pm

    Ok, I liked codeplex! =)
    I'll create the open-source there as soon as I finish organizing and commenting my code.
    You'll need it commented anyway. ;)

    But right now I'm working on my own project for time management. I want to finish it before my vacation ends, and then, use it to manage my studies and projects like FileTracking. =D

    Now I'm going to discuss projects only on Google Wave. :P
    See'ya there!! :)
    Leandro Sá Barreto
    User avatar
    Leandro
    Tabble monkey
    Tabble monkey
     
    Posts: 19
    Joined: Wed Jul 21, 2010 2:28 pm
    Location: Rio de Janeiro, Brazil

    Re: Move files with Tabbles instead of Explorer

    Postby Leandro » Tue Oct 26, 2010 8:09 pm

    Hey guys, I've already [err...finally...] got to work on EasyHookManager again.
    I forgot a lot, so I'm still reading my notes and waves to remember and understand everything.

    But this sunday I finished migrating the project to Visual Studio 2005 Express Edition, and renaming it from FileTracking to EasyHookManager.
    It was good to understand more deeply how it works, and because of that, I could make it better in many ways. I discovered a way to install/uninstall or manipulate windows services through command lines. And then, I discovered how to make the service install itself just by typing "EasyHookManager.exe /install". It's already working! I'm gonna make new command lines for it later.

    Now I am reading the notes and conversations in order to "modulate" everything in well-defined OO classes. After that, the project will be opened in codeplex.

    I was hoping to make it a surprise for you... hehehe
    But I couldn't resist to tell you because, as I remember the problems and ideas, I'm coming up with new possible solutions, especially for Tabbles' point of view. For example: Don't you think that it would be better if Tabbles just store the log for moved files? This not only would solve the "cancel" and "replace" problems, but also the MS Word too. Let's say that Word renames a "x.doc" to "x.doc.backup" during saving or execution. If Tabbles updates it as soon as it happens, that tag will be lost.
    So, I came up with the idea of storing the logs for posterior AND run-time access validation. For example: When Word renames a .doc to .doc.backup, the tag will be preserved, but Tabbles would check if the moved file is in its database. If true, then this move operation is stored in Tabbles' database or text file. (Now I'm talking about a new log, created by Tabbles, and not by EasyHookManager. So this log would be smaller than mine, because Tabbles would store only the entries about tagged files, discarding any others.) After the storing, Tabbles could guarantee the validation for each entry by 2 ways:

    1- On file access. Everytime Tabbles access a tagged file like x.doc and don't find the file in its original path, Tabbles just need to look up this original path inside its own log. If the file was moved or renamed to "x.doc.backup", Tabbles will know it through its log, and then will update the tag automatically. Wait! I know that it's not a good news! Actually, I preferred to tell you the worst case. So don't worry! Although the x.doc.backup is destroyed and a new x.doc is created, the move operation still exists in log!(because of step 10 below) All that Tabbles have to do, is look up again when the user requests x.doc.backup! Tabbles won't find it in file system, because was destroyed by Word, but Tabbles will find it inside its log! Then Tabbles can verify if the original path (x.doc) still exists. (Step 08 below) If true, the tag is updated again! if not, that means that the file was deleted or something... (Step 07 below) Note that all this processes will happen only when needed, in very specific cases. The next idea is complementary, to solve the gaps of this one.

    2- On time elapse. It doesn't matter if the first idea above doesn't work ever -since it needs user acesses to trigger it. Tabbles could validate every entry after pre-determined hours or days elapsed since they were added. This would be automatically. So, even if the first idea above doesn't happen, or happens and make Tabbles tag the x.doc.backup file instead of the x.doc, Tabbles would certainly verify every entry again before delete it. (Steps 02 and 10 below) This way, if in the next day Tabbles finds out that the tag x.doc.backup doesn't exist anymore, it will be restored to x.doc during deletion of the original move operation triggered by Word! (Step 08 below) In case of doubts, you can even make Tabbles ask the user which of the files is the correct one! (but don't think it is necessary...)

    Anyway, the basis is:
    00- Tabbles started.
    01- If user is accessing a file, then >> Jump to 5.
    02- If the log timer elapsed, then >> Jump to 4.
    03- Go back to 1 or go take a coffe. =)
    04- Load oldest log entry to memory. Jump to 8.
    05- Didn't find the file in file system? >> Look up in the log. ELSE, >> go to 3.
    06- IF the file path was found inside the log, THEN >> Load that entry to memory.
    07- ELSE, >> Display message "File not found". Start some smart search or go to 3.
    08- If the "source path" in loaded log entry exists, then >> Update the tag with this source path.
    09- If the "destination path" in loaded log entry exists, then >> Update the tag with this new path.
    10- If you come here from 2, then >> Delete this log entry from the log.
    11- Go to 3.

    Note that my order makes the "destination path" remain over the source path (it can always replace the source path).
    Maybe there's some bug in it, but should be just details...
    I can develop a class for this system if you want, and then make it be a complementary part of the open-source project for FileTracking.

    Anyway, I guess these two ideas can solve all the problems until now! Even if the move operation is cancelled or have the file name renamed, I guess that Tabbles can make this post testing to assure integrity. Maybe we just need to test this "rename" problem to see how it works. but I don't feel it like a big problem now.

    That's all! =D
    Let me know what topic on forum do you want me to discuss the project.
    It is possible to new ideas to come up!
    See'ya next days!

    PS: I'm thinking about releasing each class of the project as soon as I finish them.
    PS2: I've lost first place in my business competition, but I'm first place again! :D
    PS3: I posted here because google groups cut my text.
    Leandro Sá Barreto
    User avatar
    Leandro
    Tabble monkey
    Tabble monkey
     
    Posts: 19
    Joined: Wed Jul 21, 2010 2:28 pm
    Location: Rio de Janeiro, Brazil

    Re: Move files with Tabbles instead of Explorer

    Postby Andrea » Wed Oct 27, 2010 11:34 am

    Hello Leandro!

    Good to hear from you again... we were fearing you disappeard! :mrgreen:
    All of this sounds very exciting - cool stuff indeed. Now:

    - do you have an approximate and realistic release time for the project/code?
    - not sure you got my previous email, but we may be able to provide you a license of VS2008 or 2010...just let me know.

    Thanks,

    Andrea
    User avatar
    Andrea
    Tabble baker
    Tabble baker
     
    Posts: 734
    Joined: Sat Jun 20, 2009 9:07 pm
    Location: Copenhagen, Denmark

    Re: Move files with Tabbles instead of Explorer

    Postby Leandro » Thu Oct 28, 2010 7:42 pm

    Hi Andrea! :)

    Andrea wrote:- not sure you got my previous email,

    What email? o.o

    Andrea wrote:- we may be able to provide you a license of VS2008 or 2010...just let me know.

    Seriously!??!? =DD
    I would love it!! *-* *-*
    Is it a commercial license? :D
    In affirmative case, any of the versions would be greeeeeeeeaaaaaaaatt!! :D :D

    Andrea wrote:- do you have an approximate and realistic release time for the project/code?

    err... not... ^^"
    Ok! I'm gonna work a bit more this weekend and I promisse you that this monday I'm gonna put a working version on codeplex! :)
    Even if the new EasyHookManager is not done I have some backup from the last FileTracking to post at least like a full preview.
    But I'll try to finish the new one until there.
    Thanks for the offer!! :D
    Leandro Sá Barreto
    User avatar
    Leandro
    Tabble monkey
    Tabble monkey
     
    Posts: 19
    Joined: Wed Jul 21, 2010 2:28 pm
    Location: Rio de Janeiro, Brazil

    Re: Move files with Tabbles instead of Explorer

    Postby Andrea » Thu Oct 28, 2010 11:37 pm

    Hey there!

    I've sent you several emails actually and I started to believe that you didn't like me :o
    Good to know it's not like that :D

    Let's communicate per PM on the forum then, ok?

    I'll write you something later!

    Thanks,

    Andrea
    User avatar
    Andrea
    Tabble baker
    Tabble baker
     
    Posts: 734
    Joined: Sat Jun 20, 2009 9:07 pm
    Location: Copenhagen, Denmark

    Re: Move files with Tabbles instead of Explorer

    Postby Leandro » Tue Nov 02, 2010 3:13 am

    Oh my goooooooooooood!!! DDD=
    I just can't believe I didn't see your email on July, 29!!! =/
    I'm soooo sooooorry!!! I don't know what happened!!!
    Probably I thought it was just another message alert from the forum...
    I always answer messages, although with some delay...
    The "missing" email has the subject "Ciao Leandro".
    Very interesting your experience with "tele-working"! =)
    I'm sending you a PM to discuss everything now.
    And I've never had reasons to unlike you!!! =-)
    Thanks for the proposals! =D
    Leandro Sá Barreto
    User avatar
    Leandro
    Tabble monkey
    Tabble monkey
     
    Posts: 19
    Joined: Wed Jul 21, 2010 2:28 pm
    Location: Rio de Janeiro, Brazil

    Re: Move files with Tabbles instead of Explorer

    Postby Leandro » Thu Nov 04, 2010 4:19 am

    Infortunately, EasyHookManager is not working yet...
    Let's say I'm kind of reassembling it from scratch... :|
    I guess I would finish this new project this weekend...
    The old FileTracking works, but it's not commented... :mrgreen:
    But which do you prefer? Is this FiletTracking useful?
    If you say so, I can upload it right now.
    Sorry this mess... :(
    Leandro Sá Barreto
    User avatar
    Leandro
    Tabble monkey
    Tabble monkey
     
    Posts: 19
    Joined: Wed Jul 21, 2010 2:28 pm
    Location: Rio de Janeiro, Brazil

    Re: Move files with Tabbles instead of Explorer

    Postby Andrea » Thu Nov 04, 2010 10:15 am

    Hey there!

    sorry for taking a while to answer you... Maurizio has been a bit sick in the past days - but he's writing back to you right now :-)

    Thanks,

    A.
    User avatar
    Andrea
    Tabble baker
    Tabble baker
     
    Posts: 734
    Joined: Sat Jun 20, 2009 9:07 pm
    Location: Copenhagen, Denmark

    Re: Move files with Tabbles instead of Explorer

    Postby Maurizio » Thu Nov 04, 2010 10:33 am

    Leandro,

    I've read this message with big difficulty. Next time you post pseudocode, pleeease do not use goto, but "do...while" or "repeat...until" or "foreach" or "for...next". (Or better, use a functional language :) )

    That said, it seems to me what you are proposing is equivalent to the following: since we don't know for sure where a file is, then instead of storing a single path for each file, store a list of paths for each file (the meaning of the list would be: "the file is in one of these paths, I don't know exactly which one until I check the disk"). Then, when the user tries to open the file, look in all these paths, and you will find it in exactly one of them.

    A problem arises: the database grows more and more, as the path list of each file only grows and never shrinks. To solve this problem, if I'm not mistaken, you are adding a thread which periodically checks, for each file, which path is the correct one, and removes the other paths for the database. (Let us call this operation "trimming" the list). This prevents the path list of each file from growing to the point of slowing down Tabbles too much.

    Or maybe you are not thinking of adding a thread, but want to do the trimming each time the user tries to access (open) a file.

    Is this a good sum up of what you are saying? Could you make a practical example which shows how the data structures evolve over time? FOr instance:

    -Suppose a a file C:\foo.pdf is in tabble T1. At this point, file foo.pdf has only one possible path in its path list: [C:\foo.pdf]

    -With Explorer, I move the file to D:\foo.pdf.

    -the tabble T1 still contains C:\foo.pdf, but the path list for C:\foo.pdf is now [C:\foo.pdf ; D:\foo.pdf]

    and so on.

    ____

    Currently I suspect there can be errors if the trimming process runs at the wrong time. However I can't say more until I understand the algo completely.

    _______

    Changing topic, I was hoping for a different approach, namely to detect (via injection) that this dialog (http://gyazo.com/1bd7636c70770ce2afe29b03a05a5993.png) appeared, and that a specific button of this dialog has been pressed. AFAIK, this should be possible via sniffing the window handles. But I might be mistaken.
    User avatar
    Maurizio
    Tabble baker
    Tabble baker
     
    Posts: 196
    Joined: Fri Mar 20, 2009 3:53 pm
    Location: Pescara, Italy

    Re: Move files with Tabbles instead of Explorer

    Postby Leandro » Thu Nov 04, 2010 9:42 pm

    PS: I got tired writing this... :|
    You'll probably get tired understanding everything again! :?
    Sorry, you don't need to read now. Make yourself comfortable! ;)



    Perfect words!!! I just couldn't speak that simple!! :oops:
    Well, you've gone a bit far than I thought for this approuch.
    I was thinking about a simple extern txt file to this "path list".
    But storing this "path list" directly into database registers was very interesting!
    Anyway, that is not an efficient solution for this kind of problem, as you've already noticed.
    Even though, I liked your "path list" idea inside Tabbles database!
    But let me change it: Put this entire path list in a separate table!
    i.e: This would be a single register in this new table.
    [tbPathChange]
    idPathChange=1
    sourcePathChange="C:\foo1.pdf"
    destinyPathChange="D:\foo2.pdf"
    timePathChange="11/04/2010 17:00"

    Now, we have to consider that this problem barely happens frequently.
    That's why I've suggested such complex and process-consuming solution.
    Since it wouldn't happen frequently, the "standby" memory and process costs of this solution must be minimal.
    So, in my original idea, this "thread", like you said, would be periodical (let's say twice a week?) and since it would be an EXTERN txt file (or a new table like in the example above) it wouldn't be necessary to check EVERY TAGGED FILE from Tabbles database, but ONLY this txt log file (or all the FEW entries in this SMALL new table). Remember that these entries would be checked and DELETED twice a week.

    I guess this periodical "thread" wouldn't be that hard, especially in this so rare case: Probably in 90% of the times this "thread" executes, it would find NOTHING inside the log to process.
    And please note that all of this process about "the file is in one of these paths, I don't know exactly which one until I check the disk" WOULD HAPPEN ONLY IF the original path inside Tabbles database is not found during user access. Again, probably in 90% of the times an user access a file through Tabbles, the file path would be OK, accessed, executed, and NO ADDITIONAL PROCESS would happen about this "crazy" solution. UNLESS, of course, Tabbles finds out that the requested file is missing. THEN, in this very moment, finally, all of this process to discover where the file is would come up!

    Ok, let's see this in practice:
    Maybe you have a code like this to open a file: (in C#)

    //imagine the content of filepath is "C:\foo1.pdf"
    private void OpenFile(string filepath)
    {
    .//This method returns True if the file exists
    .if (System.IO.File.Exists(filepath)==true)
    .{
    ..//this executes the file in a given path
    ..System.Diagnostics.Process.Start(filepath);
    .}
    .else
    .{
    ..//Displays a "file missing" message to the user.
    ..System.Windows.Forms.MessageBox.ShowDialog( "The requested file is missing." );
    .}
    }

    Now, all you have to add to this code is just encapsulate this MessageBox with a simple IF that calls my solution method (which, by the way, can be from an extern DLL or from an intern class). I'm gonna exemplify:

    //imagine the content of filepath variable is "C:\foo1.pdf"
    private void OpenFile(string filepath)
    {
    .If (System.IO.File.Exists(filepath)==true)
    .{
    ..System.Diagnostics.Process.Start(filepath);
    .}
    .else
    .{
    ..//This method would be a calling to my solution, that wouuld search for a new path inside log
    ..//It would return the new path of the file, which was stored in log, and could be "D:\foo2.pdf"
    ..//If no path is found inside the log, then it may return an empty string or message.

    ..string newPath = SearchNewPathInsideLog( filepath );
    ..If ( System.IO.File.Exists(newPath)==true )
    ..{
    ...System.Diagnostics.Process.Start(newPath);
    ..}
    ..else
    ..{

    ...System.Windows.Forms.MessageBox.ShowDialog( "The requested file is missing." );
    ..}
    .}
    }

    So, if the original filepath is NOT missing, no additional operation happen!
    You may, of course, modify it to be more "professional" and less redundant.
    I was going to clarify a bit more, but I guess maybe this is enough for now.

    What errors have you found in this "trimming" operation?
    Probably you really need to filter by "timePathChange" (see above) before "trimming" it.
    It would filter all new entries to check/delete only those that have already expired.
    That would avoid losses if the "trimming" is called right after a move operation.

    How does it seem to you?
    Do you think many files would be moved by explorer?
    And if so, do you think this algo would be very consuming?
    I'm gonna say again that I would be happy in helping with the development of this class/code! ;)



    Maurizio wrote:Changing topic, I was hoping for a different approach, namely to detect (via injection) that this dialog (http://gyazo.com/1bd7636c70770ce2afe29b03a05a5993.png) appeared, and that a specific button of this dialog has been pressed. AFAIK, this should be possible via sniffing the window handles. But I might be mistaken.


    Well, if you know the name of this window/function, then we would try to inject it
    I guess you'll have to ask this question to Sujay, 'cause maybe he knows it.
    But if you want my opinion, why would Microsoft make an API for this window?
    I mean, it's not supposed to be called/accessed by an application.
    The move operation is called by anyone, but this box might be called directly by system.
    And one more thing: In my Windows XP there's no such window, at least with this options.
    There's only 2 buttons: Replace or cancel. What's the technical difference between them?
    Anyway, I'm sure I know less than you. And nothing is impossible in cyberspace... hehehe
    If you tell me more about "sniffing the window handlers" maybe I can discover something.
    Good luck! See'ya!
    Leandro Sá Barreto
    User avatar
    Leandro
    Tabble monkey
    Tabble monkey
     
    Posts: 19
    Joined: Wed Jul 21, 2010 2:28 pm
    Location: Rio de Janeiro, Brazil

    PreviousNext

    • Similar topics
      Replies
      Views
      Author

    Return to Development

    Who is online

    Users browsing this forum: No registered users and 0 guests

    cron