Changeset 5795 for 2014


Ignore:
Timestamp:
2015-01-02 16:58:31 (5 years ago)
Author:
mikrkana
Message:

Korjattu bugeja.

Location:
2014/tet/FileWatcher
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • 2014/tet/FileWatcher/FileWatcher/Executable.cs

    r4833 r5795  
    6464        { 
    6565            int kauttaviivanPaikka = 0; 
     66            bool loytyiko = false; 
    6667            String nimi = ""; 
    6768            for (int i = Path.Length - 1; i >= 0; i--) 
     
    7071                { 
    7172                    kauttaviivanPaikka = i; 
     73                    loytyiko = true; 
    7274                    break; 
    7375                } 
    7476            } 
    75             nimi = Path.Substring(kauttaviivanPaikka + 1); 
     77            if (loytyiko) 
     78                nimi = Path.Substring(kauttaviivanPaikka + 1); 
     79            else 
     80                nimi = Path; 
    7681            return nimi; 
    7782        } 
  • 2014/tet/FileWatcher/FileWatcher/MainWindow.xaml.cs

    r4833 r5795  
    7373        private void directory_TextChanged(object sender, TextChangedEventArgs e) 
    7474        { 
    75  
     75            if (directory.Text != DIRECTORY_DEFAULT_TEXT) 
     76            { 
     77                Program.SelectedFolder = directory.Text; 
     78            } 
     79            if (directory.Text == String.Empty) Program.SelectedFolder = null; 
    7680        } 
    7781 
  • 2014/tet/FileWatcher/FileWatcher/Program.cs

    r4833 r5795  
    117117            AddMessage("Verifying inputs..."); 
    118118 
    119             if (SelectedFolder == "" && SelectedFolder == MainWindow.DIRECTORY_DEFAULT_TEXT) 
     119            if (SelectedFolder == "" || SelectedFolder == MainWindow.DIRECTORY_DEFAULT_TEXT) 
    120120            { 
    121121                AddMessage("The folder path is empty!"); 
     
    291291            jobs.Add(changedFile); 
    292292 
    293             // wait until file is not locked anymore 
     293            /*// wait until file is not locked anymore 
    294294            while (IsFileLocked(file)) 
    295295            { 
    296296                AddMessageFromAnotherThread("File locked, waiting for it to be released before continuing."); 
    297297                Thread.Sleep(5000); 
    298             } 
     298            }*/ 
     299 
     300            int waitedTime = 0; 
     301            const int MAXIMUM_WAIT_TIME = 60000; // minuutti 
     302            // wait until file is not locked anymore 
     303            while (true) 
     304            { 
     305                bool? fileState = IsFileLocked(file); 
     306                if (fileState == false) break; 
     307                if (fileState == null) 
     308                { 
     309                    AddMessageFromAnotherThread("Aborting execution, file is missing."); // ehkä ajo ilman tiedostoa? 
     310                    return; 
     311                } 
     312                // jäljellä true, joten odotellaan tiedoston vapautumista 
     313 
     314                if (waitedTime > MAXIMUM_WAIT_TIME) 
     315                { 
     316                    AddMessageFromAnotherThread("Aborting execution, file has been locked for too long or something else has gone wrong."); 
     317                    return; 
     318                } 
     319 
     320                AddMessageFromAnotherThread("File locked, waiting for it to be released before continuing."); 
     321                Thread.Sleep(5000); 
     322                waitedTime += 5000; 
     323            } 
     324 
    299325 
    300326            for (int i = 0; i < ExecutablePrograms.Count; i++) 
     
    319345                catch (Win32Exception ex) 
    320346                { 
    321                     AddMessageFromAnotherThread("Execution failed, Win32 error code: " + ex.ErrorCode); 
     347                    AddMessageFromAnotherThread("Execution failed, Win32 error code: " + (ex.ErrorCode + Math.Pow(2, 31))); 
     348                    jobs.Remove(changedFile); 
    322349                } 
    323350            } 
     
    366393            if (ex.HasFileAsFirstParameter) 
    367394            { 
    368                 args = file + ex.Arguments; 
     395                args = file + " " + ex.Arguments; 
    369396            } 
    370397            else 
     
    372399                int filePos = ex.Arguments.IndexOf("%1"); 
    373400                args = ex.Arguments.Substring(0, filePos); // ennen %1 
    374                 args += " " + file; // tiedostopolku 
     401                args += file; // tiedostopolku 
    375402                args += ex.Arguments.Substring(filePos + 2); // %1 jälkeen 
    376403            } 
     
    387414        { 
    388415            int kauttaviivanPaikka = 0; 
     416            bool loytyiko = false; 
    389417            String nimi = ""; 
    390418            for (int i = path.Length - 1; i >= 0; i--) 
     
    393421                { 
    394422                    kauttaviivanPaikka = i; 
     423                    loytyiko = true; 
    395424                    break; 
    396425                } 
    397426            } 
    398             nimi = path.Substring(kauttaviivanPaikka + 1); 
     427            if (loytyiko) 
     428                nimi = path.Substring(kauttaviivanPaikka + 1); 
     429            else 
     430                nimi = path; 
    399431            return nimi; 
    400432        } 
     
    409441        /// <param name="file">File</param> 
    410442        /// <returns>Is the file locked</returns> 
    411         private static bool IsFileLocked(FileInfo file) 
     443        private static bool? IsFileLocked(FileInfo file) 
    412444        { 
    413445            FileStream stream = null; 
     
    418450                //stream = file.Open(FileMode.Open, FileAccess.Read); 
    419451            } 
    420             catch (IOException) 
     452            catch (FileNotFoundException e) 
     453            { 
     454                return null; 
     455            } 
     456            catch (IOException e) 
    421457            { 
    422458                //the file is unavailable because it is: 
  • 2014/tet/FileWatcher/FileWatcher/Properties/AssemblyInfo.cs

    r4833 r5795  
    1111[assembly: AssemblyDescription("")] 
    1212[assembly: AssemblyConfiguration("")] 
    13 [assembly: AssemblyCompany("University of Jyvaskyla")] 
     13[assembly: AssemblyCompany("")] 
    1414[assembly: AssemblyProduct("Watson")] 
    1515[assembly: AssemblyCopyright("Copyright © Miska Kananen 2014")] 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/App.g.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/App.g.i.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/FileWatcher.csproj.FileListAbsolute.txt

    r4833 r5795  
    1515C:\MyTemp\tet\FileWatcher\FileWatcher\FileWatcher\obj\x86\Debug\Options.g.cs 
    1616C:\MyTemp\tet\FileWatcher\FileWatcher\FileWatcher\bin\Debug\FileWatcher.exe.config 
     17D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\bin\Debug\FileWatcher.exe.config 
     18D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\FileWatcher.exe 
     19D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\FileWatcher.pdb 
     20D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\bin\Debug\FileWatcher.exe 
     21D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\bin\Debug\FileWatcher.pdb 
     22D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\MainWindow.baml 
     23D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\Options.baml 
     24D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\ProgramSelection.baml 
     25D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\MainWindow.g.cs 
     26D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\Options.g.cs 
     27D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\ProgramSelection.g.cs 
     28D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\App.g.cs 
     29D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\FileWatcher_MarkupCompile.cache 
     30D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\FileWatcher.g.resources 
     31D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\FileWatcher.Properties.Resources.resources 
     32D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\FileWatcher.csproj.GenerateResource.Cache 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/FileWatcher_MarkupCompile.cache

    r4833 r5795  
    55C# 
    66.cs 
    7 C:\MyTemp\tet\FileWatcher\FileWatcher\FileWatcher\obj\x86\Debug\ 
     7D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\ 
    88FileWatcher 
    99none 
    1010false 
    1111DEBUG;TRACE 
    12 C:\MyTemp\tet\FileWatcher\FileWatcher\FileWatcher\App.xaml 
     12D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\App.xaml 
    13133899149134 
    1414 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/FileWatcher_MarkupCompile.i.cache

    r4833 r5795  
    55C# 
    66.cs 
    7 C:\MyTemp\tet\FileWatcher\FileWatcher\FileWatcher\obj\x86\Debug\ 
     7D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\obj\x86\Debug\ 
    88FileWatcher 
    99none 
    1010false 
    1111DEBUG;TRACE 
    12 C:\MyTemp\tet\FileWatcher\FileWatcher\FileWatcher\App.xaml 
     12D:\Miska\MyTemp\Sovellukset\FileWatcher\FileWatcher release 1.0\FileWatcher\App.xaml 
    13133899149134 
    1414 
    15 111493282812 
     1511-289396396 
    161613-998043398 
    1717MainWindow.xaml;Options.xaml;ProgramSelection.xaml; 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/MainWindow.g.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/MainWindow.g.i.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/Options.g.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/Options.g.i.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/ProgramSelection.g.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
  • 2014/tet/FileWatcher/FileWatcher/obj/x86/Debug/ProgramSelection.g.i.cs

    r4833 r5795  
    33// <auto-generated> 
    44//     This code was generated by a tool. 
    5 //     Runtime Version:4.0.30319.18408 
     5//     Runtime Version:4.0.30319.18444 
    66// 
    77//     Changes to this file may cause incorrect behavior and will be lost if 
Note: See TracChangeset for help on using the changeset viewer.