private bool investigateFolder_logged( string strFolder, out ContentOfOrderFile coof ) { ArrayList al = new ArrayList(); coof = new ContentOfOrderFile(); foreach ( string strFN in Directory.GetFiles( strFolder, "order_*.*" ) ) switch ( Path.GetExtension( strFN ).ToLower() ) { case ".xml": case ".zip": case ".plorund": if ( Regex.IsMatch( strFN, @"\\order_\d{5,6}\.|_", RegexOptions.IgnoreCase ) ) { _sbLog.AppendFormat( "found: {0}\r\n", strFN ); al.Add( strFN.ToLower() ); } break; } string strFil = null; switch ( al.Count ) { case 0: return false; case 1: strFil = al[0] as string; break; default: foreach ( string s in al ) if ( Path.GetFileName( s ).CompareTo( _strFN ) == 0 ) strFil = s; if ( strFil==null ) if ( FSelectOrder.showDialog( this.FindForm(), al, out strFil ) != DialogResult.OK ) return false; break; } switch ( Path.GetExtension( strFil ) ) { case ".zip": case ".plorund": // en ZIP-fil vald coof.loadFromZipFile( File.ReadAllBytes( strFil ) ); return coof.getFileWithType(ContentOfOrderFile.FileType.OrderXml)!=null; } // en XML-fil vald coof.Files.Add( new ContentOfOrderFile.File( ContentOfOrderFile.FileType.OrderXml, strFil, File.ReadAllBytes( strFil ) ) ); strFil = Path.ChangeExtension( strFil, ".emf" ); if ( File.Exists( strFil ) ) coof.Files.Add( new ContentOfOrderFile.File( ContentOfOrderFile.FileType.OrderEmf, strFil, File.ReadAllBytes( strFil ) ) ); return true; }
private void callback( vdFtpWorkUnit unit, vdFtpTPStatus status, vdFtpFolder folder, vdFtpItem item, object data ) { if ( this.InvokeRequired ) { this.Invoke( _tp, unit, status, folder, item, data ); return; } try { switch ( status ) { case vdFtpTPStatus.GetFolder_Complete: if ( _strFtgFolder.CompareTo( folder.Name ) == 0 ) photographerFolderComplete( folder ); else if ( "_uppdateringar".CompareTo( folder.Name ) == 0 ) upgradeFolderComplete( folder ); else standbylistFolderComplete( folder ); break; case vdFtpTPStatus.DownloadFile_Complete: if ( item.Name.StartsWith( "order_" ) ) { _coof = new ContentOfOrderFile(); _coof.loadFromZipFile( data as MemoryStream ); _downloadStatus = _coof.getFileWithType( ContentOfOrderFile.FileType.OrderXml ) != null ? DownloadStatus.Complete : DownloadStatus.Failed; } else if ( item.Name.StartsWith( "plata_" ) ) { _upgrader = new Upgrader( data as MemoryStream ); _downloadStatus = DownloadStatus.Complete; } else if ( item.Name.EndsWith( ".pdf" ) ) { string s =Path.Combine( Global.GetTempPath(), item.Name ); using ( Stream stream = new FileStream( s, FileMode.Create ) ) (data as MemoryStream).WriteTo( stream ); } break; case vdFtpTPStatus.DownloadFile_Begin: case vdFtpTPStatus.DownloadFile_Progress: txtProgress.Text = string.Format( "Hämtar... {0}%", 100*(int)data/item.Size ); break; case vdFtpTPStatus.Error: setMessage( data.ToString() ); _downloadStatus = DownloadStatus.Failed; break; } } catch ( Exception ex ) { setMessage( ex.ToString() ); _downloadStatus = DownloadStatus.Failed; } }