git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Wed, 22 Jul 2020 13:24:53 +0000 (13:24 +0000)
committerVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Wed, 22 Jul 2020 13:24:53 +0000 (13:24 +0000)
client/Maestro/Configuration/-editor-hirtv.json [moved from client/Maestro/Configuration/editor-hirtv.json with 100% similarity]
client/Maestro/Configuration/configuration.json [moved from client/Maestro/Configuration/-configuration.json with 90% similarity]
client/Maestro/Maestro.csproj
client/Maestro/MaestroForm.Target.cs
client/MaestroShared/Commons/CustomFileCopier.cs [new file with mode: 0644]
client/MaestroShared/Configuration/ConfigurationInfo.cs
client/MaestroShared/MaestroShared.csproj
client/MaestroShared/Properties/AssemblyInfo.cs
client/MaestroShared/Targets/UNCTargetProcessor.cs

similarity index 90%
rename from client/Maestro/Configuration/-configuration.json
rename to client/Maestro/Configuration/configuration.json
index 98b39068edd03822f3276c8df3fb92c035a46f82..03c635ad85378bb34d889d397135fd82c4352bef 100644 (file)
@@ -1,6 +1,6 @@
 {\r
   "title": "Development",\r
-  "active": false,\r
+  "active": true,\r
   "startInTray": false,\r
   "enableCustomMetadataId": true,\r
   "filter": "avi",\r
@@ -12,6 +12,7 @@
   "source": {\r
     "$type": "UNCSource",\r
     "filter": "avi,wav,mxf,mts",\r
+    "useAlternateCopy":  true,\r
     "local": {\r
       "address": "file://c:/_video",\r
       "userName": "mediacube",\r
       }\r
     },\r
     {\r
-      "label": "Teszt",\r
-      "processor": "FTPTargetProcessor",\r
+      "label": "UNC Teszt",\r
+      "processor": "UNCTargetProcessor",\r
       "outputFormat": "%ID%-%SOURCENAME%",\r
       "tag": "Betöltés",\r
       "killDateDays": 7,\r
       "saveArchiveMetadata": false,\r
-      "sendEmailOnSuccess": true,\r
-      "successEmailPattern": "%JSON%",\r
-      "successEmailSubject": "%ID% - %ITEMTITLE% - %FORMAT% sikeres feltöltése",\r
-      "successEmailRecipient": "vasary@elgekko.net",\r
       "remote": {\r
-        "address": "ftp://10.10.1.105/TESZT/CHECK",\r
+        "address": "file://c:/opt1",\r
         "userName": "mediacube",\r
         "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
index 0deee7eee1f7c1f4183e4e49387feaf74959663e..612aa9a6643fa31113b27e69f81f8e31f5c681b3 100644 (file)
     <None Include="Configuration\-configuration - Copy.json">\r
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>\r
     </None>\r
-    <None Include="Configuration\-configuration.json">\r
+    <None Include="Configuration\configuration.json">\r
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>\r
     </None>\r
     <None Include="Configuration\dani-teszt-vezerlo.json">\r
     <None Include="Configuration\editor-mv.json">\r
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>\r
     </None>\r
-    <None Include="Configuration\editor-hirtv.json">\r
+    <None Include="Configuration\-editor-hirtv.json">\r
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>\r
     </None>\r
     <None Include="Configuration\global.json">\r
index 8332eb8d5511c6b201fa407e13bfab9985370ade..628ced8bcfb0e12bf51035c53bf2a7c13254d97d 100644 (file)
@@ -182,12 +182,16 @@ namespace Maestro {
             force |= target.SuccessEmailPattern == null ? false : target.SuccessEmailPattern.Contains("%");\r
             force |= target.SaveArchiveMetadata || target.SaveMorpheusMetadata || target.NexioServer;\r
             if (force && (ArchiveMetadata == null || !ArchiveMetadata.IsFilled)) {\r
-                ArchiveMetadata = GetArchiveMetadata();\r
-                if (SelectedMetadata != null && String.IsNullOrEmpty(SelectedMetadata.MetadataText))\r
-                    SelectedMetadata.MetadataText = ArchiveMetadata.itemTitle;\r
-                if (ArchiveMetadata == null) {\r
-                    MessageBox.Show(String.Format("A {0} folyamat nem futtatható kísérő adatok nélkül.", target.Label));\r
-                    return false;\r
+                //TODO eddig itt elszallt es adott hibauzenetet\r
+                try {\r
+                    ArchiveMetadata = GetArchiveMetadata();\r
+                    if (SelectedMetadata != null && string.IsNullOrEmpty(SelectedMetadata.MetadataText))\r
+                        SelectedMetadata.MetadataText = ArchiveMetadata.itemTitle;\r
+                    if (ArchiveMetadata == null) {\r
+                        MessageBox.Show(String.Format("A {0} folyamat nem futtatható kísérő adatok nélkül.", target.Label));\r
+                        return false;\r
+                    }\r
+                } catch (Exception e) { \r
                 }\r
             }\r
             //szegmens informaciook hozzaadasa\r
diff --git a/client/MaestroShared/Commons/CustomFileCopier.cs b/client/MaestroShared/Commons/CustomFileCopier.cs
new file mode 100644 (file)
index 0000000..45a0767
--- /dev/null
@@ -0,0 +1,57 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.IO;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Threading.Tasks;\r
+\r
+namespace MaestroShared.Commons {\r
+    public delegate void ProgressChangeDelegate(double Persentage, ref bool Cancel);\r
+    public delegate void Completedelegate();\r
+\r
+    class CustomFileCopier {\r
+        public CustomFileCopier(string Source, string Dest) {\r
+            this.SourceFilePath = Source;\r
+            this.DestFilePath = Dest;\r
+\r
+            OnProgressChanged += delegate { };\r
+            OnComplete += delegate { };\r
+        }\r
+\r
+        public void Copy() {\r
+            byte[] buffer = new byte[10 * 1024 * 1024]; // 1MB buffer\r
+            bool cancelFlag = false;\r
+\r
+            using (FileStream source = new FileStream(SourceFilePath, FileMode.Open, FileAccess.Read)) {\r
+                long fileLength = source.Length;\r
+                using (FileStream dest = new FileStream(DestFilePath, FileMode.CreateNew, FileAccess.Write)) {\r
+                    long totalBytes = 0;\r
+                    int currentBlockSize = 0;\r
+\r
+                    while ((currentBlockSize = source.Read(buffer, 0, buffer.Length)) > 0) {\r
+                        totalBytes += currentBlockSize;\r
+                        double persentage = (double)totalBytes * 100.0 / fileLength;\r
+\r
+                        dest.Write(buffer, 0, currentBlockSize);\r
+\r
+                        cancelFlag = false;\r
+                        OnProgressChanged(persentage, ref cancelFlag);\r
+\r
+                        if (cancelFlag == true) {\r
+                            // Delete dest file here\r
+                            break;\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+            OnComplete();\r
+        }\r
+\r
+        public string SourceFilePath { get; set; }\r
+        public string DestFilePath { get; set; }\r
+\r
+        public event ProgressChangeDelegate OnProgressChanged;\r
+        public event Completedelegate OnComplete;\r
+    }\r
+}\r
index 800f58b449c855ad4e628cc508075f6d1faa5e84..b91e135769a90689837a18c5f2e6ad81254f4542 100644 (file)
@@ -147,6 +147,7 @@ namespace MaestroShared.Configuration {
 \r
     public class UNCSource : Source {\r
         public bool FoldersAutoExpand { get; set; }\r
+        public bool UseAlternateCopy { get; set; }\r
     }\r
 \r
     public class NEXIOSource : Source {\r
index 68a8ab0eba9244c287dcc67bd438ecda7c57c169..aa910b7a8627617e99c166aef0e2ad341986d224 100644 (file)
@@ -82,6 +82,7 @@
     <Reference Include="System.Xml" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Compile Include="Commons\CustomFileCopier.cs" />\r
     <Compile Include="Commons\EdiusProject.cs" />\r
     <Compile Include="Commons\MsgBox.cs" />\r
     <Compile Include="Commons\MorpheusXML.cs" />\r
index 5936c1a59e9edc85553fa107ffdf761bcd278ad1..7f12ec86fc04cddb45d14cac65077d9e0d505453 100644 (file)
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers\r
 // by using the '*' as shown below:\r
 // [assembly: AssemblyVersion("1.0.*")]\r
-[assembly: AssemblyVersion("2.1.0.1")]\r
-[assembly: AssemblyFileVersion("2.1.0.1")]\r
+[assembly: AssemblyVersion("2.1.0.3")]\r
+[assembly: AssemblyFileVersion("2.1.0.3")]\r
index 39896b0d830aedf799bb2802295526e2c83f3916..56971554db996592152c4c05fa3af025eba4e218 100644 (file)
@@ -6,7 +6,9 @@ using MaestroShared.Target;
 using NLog;\r
 using System;\r
 using System.IO;\r
+using System.Net;\r
 using System.Text;\r
+using System.Threading.Tasks;\r
 using System.Windows.Forms;\r
 \r
 namespace MaestroShared.Targets {\r
@@ -430,12 +432,55 @@ namespace MaestroShared.Targets {
             string targetFilePath = Output;\r
             if (Parameters.TargetConfig.TemporaryCopy)\r
                 targetFilePath = Output + ".tmp";\r
-            if (Win32File.CopyFileEx(Input, targetFilePath, new CopyProgressRoutine(this.CopyProgressHandler), IntPtr.Zero, ref pbCancel, CopyFileFlags.COPY_FILE_RESTARTABLE)\r
-                && Parameters.TargetConfig.TemporaryCopy) {\r
+\r
+            bool copyResult = false;\r
+\r
+            if (Parameters.SourceConfig is UNCSource && ((UNCSource)Parameters.SourceConfig).UseAlternateCopy)\r
+                copyResult = doAlternateCopy(targetFilePath);\r
+            else\r
+                copyResult = doCopy(ref pbCancel, targetFilePath);\r
+\r
+\r
+            if (copyResult && Parameters.TargetConfig.TemporaryCopy) {\r
                 File.Move(targetFilePath, Output);\r
             }\r
         }\r
 \r
+        private bool doCopy(ref int pbCancel, string targetFilePath) {\r
+            return Win32File.CopyFileEx(Input, targetFilePath, new CopyProgressRoutine(this.CopyProgressHandler), IntPtr.Zero, ref pbCancel, CopyFileFlags.COPY_FILE_RESTARTABLE);\r
+        }\r
+\r
+        private bool doAlternateCopy(string targetFilePath) {\r
+            CustomFileCopier copier = new CustomFileCopier(Input, targetFilePath);\r
+            copier.OnProgressChanged += Copier_OnProgressChanged;\r
+            copier.Copy();\r
+            Boolean result = true;\r
+            /*\r
+            var webClient = new WebClient();\r
+            try {\r
+                webClient.DownloadProgressChanged += (s, e) => {\r
+                    Progress = e.ProgressPercentage;\r
+                };\r
+\r
+                Task task = webClient.DownloadFileTaskAsync(new Uri(Input), targetFilePath);\r
+                task.Wait();\r
+                result = task.Status == TaskStatus.RanToCompletion;\r
+            } catch (Exception e) {\r
+                result = false;\r
+                Message = e.Message;\r
+            }\r
+            */\r
+            return result;\r
+        }\r
+\r
+        private void Copier_OnProgressChanged(double Persentage, ref bool Cancel) {\r
+            Progress = (int)Persentage;\r
+        }\r
+\r
+        private void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) {\r
+            throw new NotImplementedException();\r
+        }\r
+\r
         protected virtual string GetOutputFilePath(string path, string fileName) {\r
             return "/".Equals(workingDir) ? fileName : Path.Combine(path, fileName);\r
         }\r