@@ -17,6 +17,7 @@ class MagazineSettings
1717 public string InFolderName { get ; set ; }
1818 public string OutFolderName { get ; set ; }
1919 public bool Otovarka { get ; set ; }
20+ public string OtovarkaFolderName { get ; set ; }
2021 public string Transport { get ; set ; }
2122 }
2223
@@ -38,14 +39,16 @@ class Program : Form
3839
3940 //private Timer timer = new Timer();
4041 private static System . Threading . Timer _timer ;
41-
42+
43+ string MyVersion = System . Reflection . Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version . ToString ( ) ;
4244
4345 public Program ( )
4446 {
4547
4648 // Create a simple form without a visible window
4749 this . WindowState = FormWindowState . Minimized ;
4850 this . ShowInTaskbar = false ;
51+
4952
5053
5154 // Initialize the system tray icon
@@ -83,6 +86,7 @@ public Program()
8386
8487 private void ShowLogMenuItem_Click ( object sender , EventArgs e )
8588 {
89+
8690 MyLogger . logWindow . Show ( $ "{ TrayIcon . Text } Logs") ;
8791 //MyLogger.logWindow.SetTitle();
8892 }
@@ -214,15 +218,15 @@ private void OnStart()
214218 else
215219 {
216220 MagazineSettingsList = new List < MagazineSettings > {
217- new MagazineSettings { Name = "Asino" , KkmNumber = 1 , Otovarka = true , InFolderName = "In" , OutFolderName = "Out" , Transport = "ftp" }
218- , new MagazineSettings { Name = "Bakchar" , KkmNumber = 2 , Otovarka = false , InFolderName = "In1" , OutFolderName = "Out1" , Transport = "ftp" }
221+ new MagazineSettings { Name = "Asino" , KkmNumber = 1 , Otovarka = true , OtovarkaFolderName = "Otovarka" , InFolderName = "In" , OutFolderName = "Out" , Transport = "ftp" }
222+ , new MagazineSettings { Name = "Bakchar" , KkmNumber = 2 , Otovarka = false , OtovarkaFolderName = "Otovarka1" , InFolderName = "In1" , OutFolderName = "Out1" , Transport = "ftp" }
219223 } ;
220224
221225 SaveMagSettingsToJSON ( MagazineSettingsList , "MagSettings.json" ) ;
222226 throw new FileNotFoundException ( "MagSettings.json not found" ) ;
223227 }
224228
225- TrayIcon . Text = TrayIcon . Text + " " + programSettings . TransferSide ;
229+ TrayIcon . Text = MyVersion + " " + TrayIcon . Text + " " + programSettings . TransferSide ;
226230
227231 //create timer for run StartTransfer
228232
@@ -336,8 +340,8 @@ private static void MagasineSideTransfer(ProgramSettings programSettings, Magazi
336340 if ( magazineSettings . Otovarka )
337341 {
338342
339- string localOtovarkaPath = Path . Combine ( programSettings . RootPath , magazineSettings . Name , "Otovarka" ) ;
340- string remoteOtovarkaPath = Path . Combine ( "/" , magazineSettings . Name , "Otovarka" ) . Replace ( "\\ " , "/" ) ;
343+ string localOtovarkaPath = Path . Combine ( programSettings . RootPath , magazineSettings . Name , magazineSettings . OtovarkaFolderName ) ;
344+ string remoteOtovarkaPath = Path . Combine ( "/" , magazineSettings . Name , magazineSettings . OtovarkaFolderName ) . Replace ( "\\ " , "/" ) ;
341345
342346 MyLogger . Log . Debug ( "Check Otovarka Folders" ) ;
343347 bool notExistsFolders = false ;
@@ -356,6 +360,18 @@ private static void MagasineSideTransfer(ProgramSettings programSettings, Magazi
356360
357361 if ( ! notExistsFolders )
358362 {
363+ MyLogger . Log . Debug ( "Check Otovarka Files" ) ;
364+ if ( ! File . Exists ( localOtovarkaPath + "\\ in.flg" ) && File . Exists ( localOtovarkaPath + "\\ import.txt" ) )
365+ {
366+ MyLogger . Log . Debug ( "Check Otovarka import.txt for @" ) ;
367+ string secondLine = File . ReadLines ( localOtovarkaPath + "\\ import.txt" ) . ElementAtOrDefault ( 1 ) ;
368+ if ( secondLine != null && secondLine . Contains ( "@" ) )
369+ {
370+ MyLogger . Log . Debug ( "Upload Otovarka import@.txt" ) ;
371+ UploadImportAFile ( localOtovarkaPath , remoteOtovarkaPath ) ;
372+ }
373+ }
374+
359375 MyLogger . Log . Debug ( "Download Otovarka Files" ) ;
360376 DownloadImportFile ( remoteOtovarkaPath , localOtovarkaPath ) ;
361377 }
@@ -500,8 +516,8 @@ private static void ServerSideTransfer(ProgramSettings programSettings, Magazine
500516 if ( magazineSettings . Otovarka )
501517 {
502518
503- string localOtovarkaPath = Path . Combine ( programSettings . RootPath , magazineSettings . Name , "Otovarka" ) ;
504- string remoteOtovarkaPath = Path . Combine ( "/" , magazineSettings . Name , "Otovarka" ) . Replace ( "\\ " , "/" ) ;
519+ string localOtovarkaPath = Path . Combine ( programSettings . RootPath , magazineSettings . Name , magazineSettings . OtovarkaFolderName ) ;
520+ string remoteOtovarkaPath = Path . Combine ( "/" , magazineSettings . Name , magazineSettings . OtovarkaFolderName ) . Replace ( "\\ " , "/" ) ;
505521
506522 MyLogger . Log . Debug ( "Check Otovarka Folders" ) ;
507523 bool notExistsFolders = false ;
@@ -523,6 +539,20 @@ private static void ServerSideTransfer(ProgramSettings programSettings, Magazine
523539 MyLogger . Log . Debug ( "Upload Otovarka Files" ) ;
524540 UploadImportFile ( localOtovarkaPath , remoteOtovarkaPath , false ) ;
525541 }
542+
543+
544+ MyLogger . Log . Debug ( $ "Download Otovarka Files { importAName } ") ;
545+ TransferClient . DownloadFiles ( remoteOtovarkaPath + $ "/{ importAName } ", localOtovarkaPath + $ "\\ { importATempName } ") ;
546+
547+ if ( File . Exists ( localOtovarkaPath + $ "\\ { importATempName } ") )
548+ {
549+ if ( File . Exists ( localOtovarkaPath + $ "\\ { importAName } ") )
550+ File . Delete ( localOtovarkaPath + $ "\\ { importAName } ") ;
551+
552+ File . Move ( localOtovarkaPath + $ "\\ { importATempName } ", localOtovarkaPath + $ "\\ { importAName } ") ;
553+
554+ TransferClient . DeleteFile ( remoteOtovarkaPath + $ "/{ importAName } ") ;
555+ }
526556 }
527557
528558
0 commit comments