├── .gitignore ├── AssemblyDependencies1.dgml ├── Entities ├── Entities.csproj ├── File.cs ├── Peer.cs └── Properties │ └── AssemblyInfo.cs ├── FakeObjects ├── FakeObjects.csproj ├── FakeTransferEngine.cs └── Properties │ └── AssemblyInfo.cs ├── FreeFile.DownloadManager ├── Abstract │ ├── Factory.cs │ ├── FileSearchResult.cs │ ├── IFileInfoServerManager.cs │ ├── IFileProviderServer.cs │ ├── ISearchEngine.cs │ ├── ITransferEngine.cs │ ├── ITransferEngineFactory.cs │ └── Searchengine.cs ├── Config.cs ├── DataContainerEventArg.cs ├── FileDownloadException.cs ├── FileProviderServerManager.cs ├── FileTransferManager.cs ├── FileUtility.cs ├── FreeFile.DownloadManager.csproj ├── HostUnreachableException.cs ├── Properties │ ├── AssemblyInfo.cs │ └── DataSources │ │ └── Entities.File.datasource ├── Service References │ └── FileServer │ │ ├── FilesService.wsdl │ │ ├── Reference.cs │ │ ├── Reference.svcmap │ │ ├── configuration.svcinfo │ │ ├── configuration91.svcinfo │ │ ├── item.disco │ │ ├── item.xsd │ │ ├── item1.xsd │ │ ├── item2.xsd │ │ └── item3.xsd └── app.config ├── FreeFile.LocalFileManager ├── FreeFile.LocalFileManager.csproj ├── IFileInfoServerManager.cs └── Properties │ └── AssemblyInfo.cs ├── FreeFiles.Server ├── FreeFiles.Server.csproj └── Properties │ └── AssemblyInfo.cs ├── FreeFiles.ServerSearchEngine ├── Class1.cs ├── FreeFiles.ServerSearchEngine.csproj └── Properties │ └── AssemblyInfo.cs ├── FreeFiles.TransferEngine.WCFPNRP ├── Config.cs ├── FileReader.cs ├── FreeFiles.TransferEngine.WCFPNRP.csproj ├── PNRPManager.cs ├── PeerInfo.cs ├── PnrpTransferEngine.cs ├── PnrpTransferEngineFactory.cs ├── Properties │ └── AssemblyInfo.cs ├── WCFFileTransferClient │ └── FileTransferServiceClientClass.cs └── WCFFileTransferService │ ├── FileTransferServiceClass.cs │ ├── FileTransferServiceHost.cs │ └── IFileTransferService.cs ├── FreeFiles.UI.WinForm ├── App.config ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── FreeFiles.UI.WinForm.csproj ├── Program.cs └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── FreeFiles.sln ├── FreeFilesServerConsole ├── Abstracts │ ├── Factory.cs │ ├── IDataBaseAction.cs │ ├── ORM.cs │ └── SQLLite.cs ├── App.config ├── Config.cs ├── EF │ ├── File.cs │ ├── FilesModel.Context.cs │ ├── FilesModel.Context.tt │ ├── FilesModel.Designer.cs │ ├── FilesModel.cs │ ├── FilesModel.edmx │ ├── FilesModel.edmx.diagram │ ├── FilesModel.edmx.sql │ ├── FilesModel.tt │ ├── FreeFilesEntitiesContext.cs │ ├── Peer.cs │ └── sysdiagram.cs ├── EntityUtility.cs ├── FreeFilesServerConsole.csproj ├── IUnitOfWork.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Repository │ ├── FileRepository.cs │ ├── IFilesRepository.cs │ └── PeerRepository.cs ├── WCFServices │ ├── FilesService.cs │ ├── IFileService.cs │ ├── IServiceInitializer.cs │ └── ServiceInitializer.cs └── packages.config ├── FreeFilesServerWinForm ├── FreeFilesServer.Designer.cs ├── FreeFilesServer.cs ├── FreeFilesServerWinForm.csproj ├── Program.cs └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── LICENSE ├── README.md ├── TestConsole ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Service References │ ├── FileActionsService │ │ ├── FilesService.disco │ │ ├── FilesService.wsdl │ │ ├── FilesService.xsd │ │ ├── FilesService1.xsd │ │ ├── FilesService2.xsd │ │ ├── FilesService3.xsd │ │ ├── Reference.cs │ │ ├── Reference.svcmap │ │ ├── TestConsole.FileActionsService.File.datasource │ │ ├── configuration.svcinfo │ │ └── configuration91.svcinfo │ └── FileActionsService2 │ │ ├── FilesService.wsdl │ │ ├── Reference.cs │ │ ├── Reference.svcmap │ │ ├── TestConsole.FileActionsService2.File.datasource │ │ ├── configuration.svcinfo │ │ ├── configuration91.svcinfo │ │ ├── item.disco │ │ ├── item.xsd │ │ ├── item1.xsd │ │ ├── item2.xsd │ │ └── item3.xsd ├── TestConsole.csproj └── app.config └── UnitTest ├── DBFile.cs ├── PeersTest.cs ├── Properties └── AssemblyInfo.cs ├── TestTransferEngine.cs └── UnitTest.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # Installshield output folder 63 | [Ee]xpress 64 | 65 | # DocProject is a documentation generator add-in 66 | DocProject/buildhelp/ 67 | DocProject/Help/*.HxT 68 | DocProject/Help/*.HxC 69 | DocProject/Help/*.hhc 70 | DocProject/Help/*.hhk 71 | DocProject/Help/*.hhp 72 | DocProject/Help/Html2 73 | DocProject/Help/html 74 | 75 | # Click-Once directory 76 | publish 77 | 78 | # Publish Web Output 79 | *.Publish.xml 80 | 81 | # NuGet Packages Directory 82 | packages 83 | 84 | # Windows Azure Build Output 85 | csx 86 | *.build.csdef 87 | 88 | # Windows Store app package directory 89 | AppPackages/ 90 | 91 | # Others 92 | [Bb]in 93 | [Oo]bj 94 | sql 95 | TestResults 96 | [Tt]est[Rr]esult* 97 | *.Cache 98 | ClientBin 99 | [Ss]tyle[Cc]op.* 100 | ~$* 101 | *.dbmdl 102 | Generated_Code #added for RIA/Silverlight projects 103 | 104 | # Backup & report files from converting an old project file to a newer 105 | # Visual Studio version. Backup files are not needed, because we have git ;-) 106 | _UpgradeReport_Files/ 107 | Backup*/ 108 | UpgradeLog*.XML 109 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {49240D90-C088-4CEB-94ED-631F248D8BE6} 8 | Library 9 | Properties 10 | Entities 11 | Entities 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /Entities/File.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Entities 7 | { 8 | public sealed class File 9 | { 10 | public string FileName { get; set; } 11 | public int FileSize { get; set; } 12 | public string FileType { get; set; } 13 | public Guid PeerID { get; set; } 14 | public string PeerHostName { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Peer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Entities 7 | { 8 | public sealed class Peer 9 | { 10 | public Guid PeerID { get; set; } 11 | public string PeerHostName { get; set; } 12 | public string Comments { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Entities")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("Entities")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a9a4572c-9612-40f2-9c69-fffba65c5b0e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FakeObjects/FakeObjects.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4BDDF06D-0C74-4339-80DF-42B28151BF82} 8 | Library 9 | Properties 10 | FakeObjects 11 | FakeObjects 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {bdf446f0-3e99-4ee0-a154-ef11606794ca} 48 | FreeFile.DownloadManager 49 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /FakeObjects/FakeTransferEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using FreeFile.DownloadManager.Abstract; 7 | 8 | namespace FakeObjects 9 | { 10 | public class FakeTransferEngine : ITransferEngine 11 | { 12 | public byte[] GetFile(string filePath, string fileName, string hostURI = "", string hash = "", long partNumber = 1) 13 | { 14 | if (!filePath.EndsWith(@"\")) 15 | { 16 | filePath += @"\"; 17 | } 18 | var data=File.ReadAllBytes(filePath + fileName); 19 | return data; 20 | } 21 | 22 | public byte[] GetFile(string filename, string hash, long partNumber, string hostName) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | 27 | public byte[] GetFile(string filename, long partNumber, string hostName) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | 32 | public void SetupFileServer() 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /FakeObjects/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FakeObjects")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FakeObjects")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e5ff1e3e-7199-4f98-b66e-459ba01d3bac")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/Factory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace FreeFile.DownloadManager.Abstract 10 | { 11 | public sealed class Factory 12 | { 13 | Factory() 14 | { 15 | 16 | Assembly transferEngineAssembly = Assembly.LoadFile(Path.GetDirectoryName( Application.ExecutablePath) + "\\FreeFiles.TransferEngine.WCFPNRP.dll"); 17 | var tnaTypes = transferEngineAssembly.GetTypes(); 18 | foreach (var item in tnaTypes) 19 | { 20 | if (item.GetInterface("ITransferEngineFactory") != null) 21 | { 22 | ITransferEngineFactory ITransferEngineFactory = Activator.CreateInstance(item) as ITransferEngineFactory; 23 | this.transferEngine = ITransferEngineFactory.CreateTransferEngine(); 24 | this.fileProviderServer = this.transferEngine as IFileProviderServer; 25 | break; 26 | } 27 | } 28 | /* Create 29 | *searchEngine; 30 | */ 31 | this.searchEngine = new Searchengine(); 32 | } 33 | static readonly object sharedObject = new object(); 34 | static Factory instance; 35 | public static Factory Instance 36 | { 37 | get 38 | { 39 | if (instance == null) 40 | { 41 | lock (sharedObject) 42 | { 43 | if (instance == null) 44 | { 45 | instance = new Factory(); 46 | } 47 | } 48 | } 49 | return instance; 50 | } 51 | } 52 | ISearchEngine searchEngine; 53 | ITransferEngine transferEngine; 54 | IFileProviderServer fileProviderServer; 55 | public ISearchEngine CreateSeachEngine() 56 | { 57 | return searchEngine; 58 | } 59 | public ITransferEngine CreateTransferEngine() 60 | { 61 | return transferEngine; 62 | } 63 | 64 | public IFileProviderServer CreateFileProviderServer() 65 | { 66 | return fileProviderServer; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/FileSearchResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager.Abstract 7 | { 8 | public sealed class FileSearchResult 9 | { 10 | public string FileName { get; set; } 11 | public long Size { get; set; } 12 | public string Hash { get; set; } 13 | public string HostName { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/IFileInfoServerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager.LocalFileManagement 7 | { 8 | namespace FreeFile.DownloadManager.Abstract 9 | { 10 | public interface IFileInfoServerManager 11 | { 12 | void RegisterSharedFileInfo(string localServerName, string fileName, string hash, long size); 13 | void RemoveSharedFile(string localServerName, string fileName, string hash); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/IFileProviderServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager.Abstract 7 | { 8 | public interface IFileProviderServer 9 | { 10 | void SetupFileServer(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/ISearchEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager.Abstract 7 | { 8 | public interface ISearchEngine 9 | { 10 | List Search(string searchPattern); 11 | List SearchByFileHashCode(string hashCode); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/ITransferEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager.Abstract 7 | { 8 | public interface ITransferEngine 9 | { 10 | byte[] GetFile(string filename, string hash,long partNumber,string hostName); 11 | byte[] GetFile(string filename, long partNumber, string hostName); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/ITransferEngineFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager.Abstract 7 | { 8 | public interface ITransferEngineFactory 9 | { 10 | ITransferEngine CreateTransferEngine(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Abstract/Searchengine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Entities; 6 | 7 | namespace FreeFile.DownloadManager.Abstract 8 | { 9 | class Searchengine:ISearchEngine 10 | { 11 | public List Search(string searchPattern) 12 | { 13 | FileServer.FilesServiceClient fileServiceClient = new FileServer.FilesServiceClient(); 14 | 15 | List filesList = new List(); 16 | foreach (var file in fileServiceClient.SearchAvaiableFiles(searchPattern)) 17 | { 18 | Entities.File currentFile = new File(); 19 | currentFile.FileName = file.FileName; 20 | currentFile.FileSize = file.FileSize; 21 | currentFile.FileType = file.FileType; 22 | currentFile.PeerID = file.PeerID; 23 | currentFile.PeerHostName = file.PeerHostName; 24 | filesList.Add(currentFile); 25 | } 26 | return filesList; 27 | //List retlist = new List(); 28 | //retlist.Add(new FileSearchResult { FileName = "pooya.txt", 29 | // Hash = "BA-32-53-87-6A-ED-6B-C2-2D-4A-6F-F5-3D-84-06-C6-AD-86-41-95-ED-14-4A-B5-C8-76-21-B6-C2-33-B5-48-BA-EA-E6-95-6D-F3-46-EC-8C-17-F5-EA-10-F3-5E-E3-CB-C5-14-79-7E-D7-DD-D3-14-54-64-E2-A0-BA-B4-13", 30 | // Size = 100, 31 | // HostName = "FreeFile163b69882b3a4f18b0de878eb5f0b4b7" 32 | //}); 33 | //return retlist; 34 | 35 | } 36 | 37 | public List SearchByFileHashCode(string hashCode) 38 | { 39 | return null; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using Microsoft.Win32; 7 | 8 | namespace FreeFile.DownloadManager 9 | { 10 | public static class Config 11 | { 12 | const string FreeFileLocalHostNameKey = "FreeFileLocalHostName"; 13 | const string FreeFileLocalPortKey = "FreeFileLocalPort"; 14 | const string SharedFolderNameKey = "SharedFolderName "; 15 | 16 | public static string LocalHostyName 17 | { 18 | get 19 | { 20 | //var localHostName = Registry.CurrentUser.GetValue(FreeFileLocalHostNameKey); 21 | var localHostName = Registry.CurrentUser.GetValue(FreeFileLocalHostNameKey); 22 | string hostname = string.Empty; 23 | if (localHostName == null) 24 | { 25 | hostname = "FreeFile" + Guid.NewGuid().ToString().Replace("-", ""); 26 | Registry.CurrentUser.SetValue(FreeFileLocalHostNameKey, hostname); 27 | } 28 | else 29 | { 30 | hostname = localHostName.ToString(); 31 | } 32 | return hostname; 33 | } 34 | } 35 | 36 | public static string SharedFolder 37 | { 38 | get 39 | { 40 | var sharedFolderName = Registry.CurrentUser.GetValue(SharedFolderNameKey); 41 | string folder = string.Empty; 42 | if (sharedFolderName == null) 43 | { 44 | folder = @"C:\FreeFileDirectory"; ; 45 | Registry.CurrentUser.SetValue(SharedFolderNameKey, folder); 46 | } 47 | else 48 | { 49 | folder = sharedFolderName.ToString(); 50 | } 51 | return folder; 52 | } 53 | } 54 | 55 | public static int LocalPort 56 | { 57 | get 58 | { 59 | var localPort = Registry.CurrentUser.GetValue(FreeFileLocalPortKey); 60 | int port = 20388; 61 | if (localPort == null) 62 | { 63 | Registry.CurrentUser.SetValue(FreeFileLocalPortKey, port); 64 | } 65 | return port; 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/DataContainerEventArg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager 7 | { 8 | public sealed class DataContainerEventArg:EventArgs 9 | { 10 | public DataContainerEventArg(T data) : base() { this.Data = data; } 11 | public T Data { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/FileDownloadException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager 7 | { 8 | public sealed class FileDownloadException : Exception 9 | { 10 | public long PartNumber { get; private set; } 11 | public string FileName { get; private set; } 12 | public string Host { get; private set; } 13 | public FileDownloadException(long partNumber, string FileName, string Host, Exception innerException = null) 14 | : base("Download Failed!", innerException) 15 | { 16 | this.PartNumber = PartNumber; 17 | this.FileName = FileName; 18 | this.Host = Host; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/FileProviderServerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using FreeFile.DownloadManager.Abstract; 6 | 7 | namespace FreeFile.DownloadManager 8 | { 9 | public static class FileProviderServerManager 10 | { 11 | static IFileProviderServer FileProviderServer; 12 | public static void StartFileProviderServer() 13 | { 14 | FileProviderServer= Factory.Instance.CreateFileProviderServer(); 15 | FileProviderServer.SetupFileServer(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/FileTransferManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using FreeFile.DownloadManager.Abstract; 7 | 8 | namespace FreeFile.DownloadManager 9 | { 10 | public sealed class FileTransferManager 11 | { 12 | public class FilePartData 13 | { 14 | internal FilePartData(DownloadParameter downloadParameter, byte[] data) 15 | { 16 | DownloadParameter = downloadParameter; 17 | FileBytes = data; 18 | } 19 | public DownloadParameter DownloadParameter { get; private set; } 20 | public byte[] FileBytes{ get; private set; } 21 | } 22 | 23 | public sealed class DownloadParameter 24 | { 25 | 26 | public long AllPartsCount { get; set; } 27 | public long Part { get; set; } 28 | public string Host { get; set; } 29 | public Entities.File FileSearchResult { get; set; } 30 | } 31 | 32 | const long FilePartSizeInByte = 10240; 33 | 34 | ITransferEngine transferEngine; 35 | 36 | ISearchEngine searchEngine; 37 | 38 | List resultOfSameHashSearch; 39 | 40 | public FileTransferManager() 41 | { 42 | this.transferEngine = Factory.Instance.CreateTransferEngine(); 43 | this.searchEngine = Factory.Instance.CreateSeachEngine(); 44 | } 45 | 46 | 47 | private void StartDownload(object state) 48 | { 49 | Entities.File fileSearchResult = state as Entities.File; 50 | //Wee need to aply multiThreading to use multi host to download diferent part of file cuncurently max number of thread could be 5 thread per host in all of the application; 51 | long partcount = fileSearchResult.FileSize / FilePartSizeInByte; 52 | long mod = fileSearchResult.FileSize % FilePartSizeInByte; 53 | if (mod > 0) partcount++; 54 | for (int i = 1; i <=partcount; i++) 55 | { 56 | downloadFilePart(new DownloadParameter { FileSearchResult = fileSearchResult, Host = fileSearchResult.PeerHostName, Part = i, AllPartsCount = partcount }); 57 | } 58 | 59 | 60 | } 61 | 62 | public void CancelDownloads() 63 | { 64 | } 65 | 66 | private void downloadFilePart(DownloadParameter downloadParameter) 67 | { 68 | try 69 | { 70 | var data = transferEngine.GetFile(downloadParameter.FileSearchResult.FileName, downloadParameter.Part, downloadParameter.Host); 71 | onFilePartDownloaded(new FilePartData(downloadParameter, data)); 72 | //Error 73 | } 74 | catch(Exception ex) 75 | { 76 | throw new FileDownloadException(downloadParameter.Part, downloadParameter.FileSearchResult.FileName, downloadParameter.Host, ex); 77 | } 78 | } 79 | 80 | private void searchForSameFileBaseOnHash(object state) 81 | { 82 | var fileSearchResult =state as FileSearchResult; 83 | resultOfSameHashSearch = searchEngine.SearchByFileHashCode(fileSearchResult.Hash); 84 | onSynchronizedReadOnlyCollection(resultOfSameHashSearch); 85 | } 86 | 87 | public event EventHandler>> ExtraServerHostFondBaseOnHashSearch; 88 | 89 | private void onSynchronizedReadOnlyCollection(List searchResult) 90 | { 91 | if (ExtraServerHostFondBaseOnHashSearch != null) 92 | { 93 | ExtraServerHostFondBaseOnHashSearch(this, new DataContainerEventArg>(searchResult)); 94 | } 95 | } 96 | 97 | public event EventHandler> FilePartDownloaded; 98 | 99 | private void onFilePartDownloaded(FilePartData filePartData) 100 | { 101 | if (FilePartDownloaded != null) 102 | { 103 | FilePartDownloaded(this, new DataContainerEventArg(filePartData)); 104 | } 105 | } 106 | 107 | public List SearchFileByName(string fileName) 108 | { 109 | return this.searchEngine.Search(fileName); 110 | } 111 | 112 | public void Download(Entities.File fileSearchResult) 113 | { 114 | //var action =new Action(searchForSameFileBaseOnHash); 115 | //Task searchForSameFileBaseOnHashTask = new Task(action, fileSearchResult); 116 | //searchForSameFileBaseOnHashTask.Start(); 117 | 118 | var downloadAction = new Action(StartDownload); 119 | Task downloadActionTask = new Task(downloadAction, fileSearchResult); 120 | downloadActionTask.Start(); 121 | } 122 | 123 | public void AddFiles(List files,Entities.Peer peer) 124 | { 125 | FileServer.FilesServiceClient fsc = new FileServer.FilesServiceClient(); 126 | fsc.AddFiles(files.ToArray(), peer); 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/FileUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Security.Cryptography; 6 | using System.Text; 7 | 8 | namespace FreeFile.DownloadManager 9 | { 10 | public static class FileUtility 11 | { 12 | 13 | const int FiePartsize = 10240; 14 | public static string FindFileByHash(string path,string fileName ,string hash) 15 | { 16 | var files = Directory.GetFiles(Config.SharedFolder, fileName, SearchOption.AllDirectories); 17 | foreach (var item in files) 18 | { 19 | SHA512 sha512 = SHA512.Create(); 20 | using (FileStream fstream = new FileStream(item, FileMode.Open, FileAccess.Read)) 21 | { 22 | var computedhash = sha512.ComputeHash(fstream); 23 | if (string.Compare(BitConverter.ToString(computedhash, 0), hash, true)==0) 24 | { 25 | return item; 26 | } 27 | } 28 | } 29 | return null; 30 | } 31 | 32 | 33 | 34 | public static byte[] ReadFilePart(string fileFulePath, long partNumber) 35 | { 36 | try 37 | { 38 | using (FileStream fstream = new FileStream(fileFulePath, FileMode.Open, FileAccess.Read)) 39 | { 40 | byte[] data = null; 41 | data = File.ReadAllBytes(fileFulePath); 42 | //fstream.Seek(partNumber * FiePartsize, SeekOrigin.Begin); 43 | //fstream.Read(data, 0, FiePartsize); 44 | return data; 45 | } 46 | } 47 | catch 48 | { 49 | return null; 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/FreeFile.DownloadManager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {BDF446F0-3E99-4EE0-A154-EF11606794CA} 8 | Library 9 | Properties 10 | FreeFile.DownloadManager 11 | FreeFile.DownloadManager 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\Entities\bin\Debug\Entities.dll 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | True 66 | True 67 | Reference.svcmap 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Designer 83 | 84 | 85 | Designer 86 | 87 | 88 | Designer 89 | 90 | 91 | Designer 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | WCF Proxy Generator 109 | Reference.cs 110 | 111 | 112 | 113 | 120 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/HostUnreachableException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.DownloadManager 7 | { 8 | public sealed class HostUnreachableException:ApplicationException 9 | { 10 | public string HostName { get; private set; } 11 | public HostUnreachableException(string hostName, string message = "Host is unreachable for geting data", Exception innerexception = null) 12 | :base(message,innerexception) 13 | { 14 | HostName = hostName; 15 | 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFile.DownloadManager")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFile.DownloadManager")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("858cfe0d-af2b-4f7f-9f32-4badd5823b4b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Properties/DataSources/Entities.File.datasource: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | Entities.File, Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/FilesService.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/Reference.svcmap: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | true 6 | 7 | false 8 | false 9 | false 10 | 11 | 12 | true 13 | Auto 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/configuration.svcinfo: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/item.disco: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/item.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/item1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/item2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/Service References/FileServer/item3.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /FreeFile.DownloadManager/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FreeFile.LocalFileManager/FreeFile.LocalFileManager.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D2D8C37E-5236-4B44-A957-13AB7BD74F24} 8 | Library 9 | Properties 10 | FreeFile.LocalFileManager 11 | FreeFile.LocalFileManager 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | -------------------------------------------------------------------------------- /FreeFile.LocalFileManager/IFileInfoServerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFile.LocalFileManager 7 | { 8 | public interface IFileInfoServerManager 9 | { 10 | void RegisterSharedFileInfo(string localServerName,string fileName, string hash, long size); 11 | void RemoveSharedFile(string localServerName, string fileName, string hash); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FreeFile.LocalFileManager/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFile.LocalFileManager")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFile.LocalFileManager")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0ac20b87-d0b3-4ae3-84ba-f94da9d68cb2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFiles.Server/FreeFiles.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {AD4276B8-F0C2-4475-9C3A-39C6002150A6} 8 | Library 9 | Properties 10 | FreeFiles.Server 11 | FreeFiles.Server 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 59 | -------------------------------------------------------------------------------- /FreeFiles.Server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFiles.Server")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFiles.Server")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0dbaa221-effd-4dc6-b123-ffcd5da62868")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFiles.ServerSearchEngine/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFiles.ServerSearchEngine 7 | { 8 | public class Class1 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /FreeFiles.ServerSearchEngine/FreeFiles.ServerSearchEngine.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B2EAE48D-10CD-4B1D-B65D-56336BA821A7} 8 | Library 9 | Properties 10 | FreeFiles.ServerSearchEngine 11 | FreeFiles.ServerSearchEngine 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | -------------------------------------------------------------------------------- /FreeFiles.ServerSearchEngine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFiles.ServerSearchEngine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFiles.ServerSearchEngine")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9fc10ea7-d9e3-4ed7-bca0-9bd807f9ad8a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using Microsoft.Win32; 7 | 8 | namespace FreeFiles.TransferEngine.WCFPNRP 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/FileReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using FreeFile.DownloadManager; 7 | 8 | namespace FreeFiles.TransferEngine.WCFPNRP 9 | { 10 | static class FileReader 11 | { 12 | 13 | internal static byte[] GetFileBytes(string fileName, string hash, long partNumber) 14 | { 15 | var file=FileUtility.FindFileByHash(Config.SharedFolder, fileName, hash); 16 | return FileUtility.ReadFilePart(file, partNumber); 17 | } 18 | 19 | internal static byte[] GetFileBytes(string fileName, long partNumber) 20 | { 21 | return FileUtility.ReadFilePart(fileName, partNumber); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/FreeFiles.TransferEngine.WCFPNRP.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4374A8E0-988E-4DF0-AC9D-0AF0FA8B0FDB} 8 | Library 9 | Properties 10 | FreeFiles.TransferEngine.WCFPNRP 11 | FreeFiles.TransferEngine.WCFPNRP 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | {bdf446f0-3e99-4ee0-a154-ef11606794ca} 59 | FreeFile.DownloadManager 60 | 61 | 62 | 63 | 64 | 71 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/PNRPManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Net; 6 | using System.Net.PeerToPeer; 7 | using System.ServiceModel; 8 | using System.IO; 9 | 10 | namespace FreeFiles.TransferEngine.WCFPNRP 11 | { 12 | class PNRPManager 13 | { 14 | public PNRPManager(string classifierName, int port) 15 | { 16 | this.ClassifierName = classifierName; 17 | this.Port= port; 18 | peerName = new PeerName(classifierName, PeerNameType.Unsecured); 19 | registrations = new List(); 20 | registrations.Add(new PeerNameRegistration(peerName, this.Port, Cloud.AllLinkLocal) { UseAutoEndPointSelection=true }); 21 | //registrations.Add(new PeerNameRegistration(peerName, this.Port, Cloud.Global) { UseAutoEndPointSelection = true }); 22 | } 23 | 24 | public string ClassifierName { get; private set; } 25 | public int Port { get; private set; } 26 | List registrations = null; 27 | PeerName peerName = null; 28 | public List CurrentPOeerRegistrationInfo { get; private set; } 29 | 30 | public List Register() 31 | { 32 | List registerdPeer = new List(); 33 | foreach (var registration in registrations) 34 | { 35 | string timeStamp = string.Format("FreeFile Peer Crearted at : {0}", DateTime.Now.ToShortTimeString()); 36 | registration.Comment = timeStamp; 37 | try 38 | { 39 | try 40 | { 41 | registration.Start(); 42 | if (registerdPeer.FirstOrDefault(x => x.HostName == registration.PeerName.PeerHostName) == null) 43 | { 44 | PeerInfo peerInfo = new PeerInfo(registration.PeerName.PeerHostName, registration.PeerName.Classifier, registration.Port); 45 | peerInfo.Comment = registration.Comment; 46 | registerdPeer.Add(peerInfo); 47 | } 48 | } 49 | catch { } 50 | } 51 | catch (PeerToPeerException PEX) 52 | { 53 | throw new Exception(PEX.InnerException.Message); 54 | } 55 | } 56 | this.CurrentPOeerRegistrationInfo = registerdPeer; 57 | return registerdPeer; 58 | } 59 | 60 | public void Leave() 61 | { 62 | foreach (var registration in registrations) 63 | { 64 | registration.Stop(); 65 | } 66 | } 67 | 68 | 69 | public List ResolveByPeerHostName(string peerHostName) 70 | { 71 | try 72 | { 73 | if (string.IsNullOrEmpty(peerHostName)) 74 | throw new ArgumentException("Cannot have a null or empty host peer name."); 75 | 76 | PeerNameResolver resolver = new PeerNameResolver(); 77 | List foundPeers = new List(); 78 | var resolvedName = resolver.Resolve(new PeerName(peerHostName, PeerNameType.Unsecured), Cloud.AllLinkLocal); 79 | foreach (var foundItem in resolvedName) 80 | { 81 | foreach (var endPointInfo in foundItem.EndPointCollection) 82 | { 83 | PeerInfo peerInfo = new PeerInfo(foundItem.PeerName.PeerHostName, foundItem.PeerName.Classifier,endPointInfo.Port); 84 | peerInfo.Comment = foundItem.Comment; 85 | foundPeers.Add(peerInfo); 86 | } 87 | 88 | } 89 | return foundPeers; 90 | 91 | } 92 | catch (PeerToPeerException px) 93 | { 94 | throw new Exception(px.InnerException.Message); 95 | } 96 | 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/PeerInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | 7 | namespace FreeFiles.TransferEngine.WCFPNRP 8 | { 9 | sealed class PeerInfo 10 | { 11 | public string HostName { get; private set; } 12 | 13 | public int Port { get; private set; } 14 | 15 | public string Comment { get; set; } 16 | 17 | public string Classifier { get; set; } 18 | 19 | public PeerInfo(string hostName,string Classifier, int port) 20 | { 21 | this.HostName = hostName; 22 | this.Port = port; 23 | this.Classifier = Classifier; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/PnrpTransferEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using FreeFile.DownloadManager.Abstract; 6 | using System.ServiceModel; 7 | using FreeFile.DownloadManager; 8 | using FreeFiles.TransferEngine.WCFPNRP.WCFFileTransferService; 9 | using FreeFiles.TransferEngine.WCFPNRP.WCFFileTransferClient; 10 | 11 | namespace FreeFiles.TransferEngine.WCFPNRP 12 | { 13 | public class PnrpTransferEngine : ITransferEngine, IFileProviderServer 14 | { 15 | static readonly object SharedObject = new object(); 16 | static PNRPManager pnrpManager; 17 | public PnrpTransferEngine(string localServerClassifier, int localServerPort) 18 | { 19 | if (pnrpManager == null) 20 | { 21 | lock (SharedObject) 22 | { 23 | if (pnrpManager == null) 24 | { 25 | 26 | pnrpManager = new PNRPManager(localServerClassifier, localServerPort); 27 | } 28 | } 29 | } 30 | } 31 | 32 | byte[] ITransferEngine.GetFile(string filename, string hash, long partNumber, string hostName) 33 | { 34 | var peers = pnrpManager.ResolveByPeerHostName(hostName); 35 | byte[] data = null; 36 | if (peers != null && peers.Count > 0) 37 | { 38 | bool dataretrived = false; 39 | FileTransferServiceClientClass Client = null; 40 | System.ServiceModel.Channels.Binding netBinding = new NetTcpBinding(SecurityMode.None); 41 | 42 | //foreach (var peer in peers) 43 | //{ 44 | EndpointAddress endpointAddress = new EndpointAddress(string.Format("net.tcp://{0}:{1}/TransferEngine", peers.FirstOrDefault().HostName, peers.FirstOrDefault().Port)); 45 | Client = new FileTransferServiceClientClass(netBinding, endpointAddress); 46 | try 47 | { 48 | data = Client.TransferFile(filename, hash, partNumber); 49 | dataretrived = true; 50 | //break; 51 | } 52 | catch 53 | { 54 | } 55 | //} 56 | if (!dataretrived) throw new HostUnreachableException(hostName); 57 | } 58 | else throw new HostUnreachableException(hostName); 59 | return data; 60 | 61 | } 62 | 63 | byte[] ITransferEngine.GetFile(string filename, long partNumber, string hostName) 64 | { 65 | var peers = pnrpManager.ResolveByPeerHostName(hostName); 66 | byte[] data = null; 67 | if (peers != null && peers.Count > 0) 68 | { 69 | bool dataretrived = false; 70 | FileTransferServiceClientClass Client = null; 71 | System.ServiceModel.Channels.Binding netBinding = new NetTcpBinding(SecurityMode.None); 72 | 73 | //foreach (var peer in peers) 74 | //{ 75 | EndpointAddress endpointAddress = new EndpointAddress(string.Format("net.tcp://{0}:{1}/TransferEngine", peers.FirstOrDefault().HostName, peers.FirstOrDefault().Port)); 76 | Client = new FileTransferServiceClientClass(netBinding, endpointAddress); 77 | try 78 | { 79 | //######## 80 | data = Client.TransferFile(filename, partNumber); 81 | dataretrived = true; 82 | //break; 83 | } 84 | catch 85 | { 86 | } 87 | //} 88 | if (!dataretrived) throw new HostUnreachableException(hostName); 89 | } 90 | else throw new HostUnreachableException(hostName); 91 | return data; 92 | 93 | } 94 | 95 | 96 | void IFileProviderServer.SetupFileServer() 97 | { 98 | 99 | var peers = pnrpManager.Register(); 100 | if (peers == null || peers.Count == 0) throw new Exception("Host not registerd!"); 101 | var fileTransferServiceHost = new FileTransferServiceHost(); 102 | fileTransferServiceHost.DoHost(peers); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/PnrpTransferEngineFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using FreeFile.DownloadManager; 7 | using FreeFile.DownloadManager.Abstract; 8 | using Microsoft.Win32; 9 | 10 | namespace FreeFiles.TransferEngine.WCFPNRP 11 | { 12 | public sealed class PnrpTransferEngineFactory : ITransferEngineFactory 13 | { 14 | public ITransferEngine CreateTransferEngine() 15 | { 16 | return new PnrpTransferEngine(Config.LocalHostyName, Config.LocalPort); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFiles.TransferEngine.WCFPNRP")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFiles.TransferEngine.WCFPNRP")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("6af3a6ef-30e2-49fa-9482-56f707c8d16e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/WCFFileTransferClient/FileTransferServiceClientClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceModel; 5 | using System.Text; 6 | using FreeFiles.TransferEngine.WCFPNRP.WCFFileTransferService; 7 | 8 | namespace FreeFiles.TransferEngine.WCFPNRP.WCFFileTransferClient 9 | { 10 | [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single, UseSynchronizationContext = false)] 11 | class FileTransferServiceClientClass : System.ServiceModel.ClientBase 12 | { 13 | public FileTransferServiceClientClass() :base() 14 | { 15 | } 16 | 17 | public FileTransferServiceClientClass(string endpointConfigurationName) : 18 | base(endpointConfigurationName) 19 | { 20 | } 21 | 22 | public FileTransferServiceClientClass(string endpointConfigurationName, string remoteAddress) : 23 | base(endpointConfigurationName, remoteAddress) 24 | { 25 | } 26 | 27 | public FileTransferServiceClientClass(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 28 | base(endpointConfigurationName, remoteAddress) 29 | { 30 | } 31 | 32 | public FileTransferServiceClientClass(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 33 | base(binding, remoteAddress) 34 | { 35 | 36 | } 37 | 38 | public byte[] TransferFile(string fileName,string hash, long partNumber) 39 | { 40 | byte[] _bytes = base.Channel.TransferFileByHash(fileName, hash, partNumber); 41 | return _bytes; 42 | } 43 | 44 | public byte[] TransferFile(string fileName, long partNumber) 45 | { 46 | //## 47 | byte[] _bytes = base.Channel.TransferFile(fileName, partNumber); 48 | return _bytes; 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/WCFFileTransferService/FileTransferServiceClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ServiceModel; 6 | using System.ServiceModel.Channels; 7 | 8 | 9 | namespace FreeFiles.TransferEngine.WCFPNRP.WCFFileTransferService 10 | { 11 | [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single, UseSynchronizationContext = false)] 12 | class FileTransferServiceClass :IFileTransferService 13 | { 14 | 15 | public byte[] TransferFileByHash(string fileName,string hash, long partNumber) 16 | { 17 | return FileReader.GetFileBytes(fileName,hash, partNumber); 18 | } 19 | 20 | public byte[] TransferFile(string fileName, long partNumber) 21 | { 22 | return FileReader.GetFileBytes(fileName, partNumber); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/WCFFileTransferService/FileTransferServiceHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.ServiceModel; 5 | using System.ServiceModel.Channels; 6 | using System.Text; 7 | 8 | namespace FreeFiles.TransferEngine.WCFPNRP.WCFFileTransferService 9 | { 10 | sealed class FileTransferServiceHost 11 | { 12 | public void DoHost(List peers) 13 | { 14 | Uri[] Uris = new Uri[peers.Count]; 15 | 16 | string Address = string.Empty; 17 | for (int i = 0; i < peers.Count; i++) 18 | { 19 | Address = string.Format("net.tcp://{0}:{1}/TransferEngine", peers[i].HostName, peers[i].Port); 20 | Uris[i] = new Uri(Address); 21 | } 22 | 23 | FileTransferServiceClass currentPeerServiceProxy = new FileTransferServiceClass(); 24 | ServiceHost _serviceHost = new ServiceHost(currentPeerServiceProxy, Uris); 25 | NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None); 26 | _serviceHost.AddServiceEndpoint(typeof(IFileTransferService), tcpBinding, ""); 27 | 28 | _serviceHost.Open(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FreeFiles.TransferEngine.WCFPNRP/WCFFileTransferService/IFileTransferService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ServiceModel; 6 | 7 | namespace FreeFiles.TransferEngine.WCFPNRP.WCFFileTransferService 8 | { 9 | [ServiceContractAttribute] 10 | interface IFileTransferService 11 | { 12 | [OperationContractAttribute(IsOneWay = false)] 13 | byte[] TransferFileByHash(string fileName,string hash, long partNumber); 14 | 15 | [OperationContractAttribute(IsOneWay = false)] 16 | byte[] TransferFile(string fileName, long partNumber); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using FreeFile.DownloadManager; 11 | using FreeFile.DownloadManager.Abstract; 12 | using System.IO; 13 | 14 | namespace FreeFiles.UI.WinForm 15 | { 16 | public partial class FreeFilesForm : Form 17 | { 18 | public FreeFilesForm() 19 | { 20 | InitializeComponent(); 21 | } 22 | FileTransferManager fileTransferManager; 23 | 24 | private void FreeFilesForm_Load(object sender, EventArgs e) 25 | { 26 | fileTransferManager = new FileTransferManager(); 27 | fileTransferManager.FilePartDownloaded += fileTransferManager_FilePartDownloaded; 28 | } 29 | 30 | void fileTransferManager_FilePartDownloaded(object sender, DataContainerEventArg e) 31 | { 32 | List> data = new List>(); 33 | data.Add(new Tuple(e.Data.DownloadParameter, e.Data.FileBytes)); 34 | if (e.Data.DownloadParameter.AllPartsCount == e.Data.DownloadParameter.Part) 35 | { 36 | saveFile(data); 37 | } 38 | } 39 | 40 | private void saveFile(List> data) 41 | { 42 | CheckForIllegalCrossThreadCalls = false; 43 | var lst = data.OrderBy(x => x.Item1.Part).ToList(); 44 | var bytes = new List(); 45 | for (int i = 0; i foundFileInfoList = fileTransferManager.SearchFileByName(txtFileName.Text); 65 | this.dataGridView1.DataSource = foundFileInfoList; 66 | } 67 | } 68 | 69 | 70 | 71 | private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) 72 | { 73 | Entities.File fileSearchResult = dataGridView1.Rows[e.RowIndex].DataBoundItem as Entities.File; 74 | this.fileTransferManager.Download(fileSearchResult); 75 | } 76 | 77 | private void UploadBTN_Click(object sender, EventArgs e) 78 | { 79 | DialogResult result = openFileDialog1.ShowDialog(); 80 | if (result == DialogResult.OK) 81 | { 82 | // 83 | // The user selected a folder and pressed the OK button. 84 | // We print the number of files found. 85 | // 86 | List addedFiles = new List(); 87 | Entities.Peer peerType = new Entities.Peer(); 88 | 89 | Entities.File FileType = new Entities.File(); 90 | FileInfo fInfo = new FileInfo(openFileDialog1.FileName); 91 | FileType.FileName = openFileDialog1.FileName; 92 | FileType.FileSize = (int)fInfo.Length; 93 | FileType.FileType = Path.GetExtension(openFileDialog1.FileName); 94 | FileType.PeerHostName = Config.LocalHostyName; 95 | peerType.PeerID=FileType.PeerID = Guid.NewGuid(); 96 | addedFiles.Add(FileType); 97 | 98 | 99 | peerType.PeerHostName = Config.LocalHostyName; 100 | fileTransferManager.AddFiles(addedFiles,peerType); 101 | MessageBox.Show("Files Added!"); 102 | } 103 | } 104 | 105 | private void txtFileName_TextChanged(object sender, EventArgs e) 106 | { 107 | 108 | } 109 | 110 | private void label1_Click(object sender, EventArgs e) 111 | { 112 | 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/FreeFiles.UI.WinForm.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5E42DDBF-A413-4D0E-91EE-6B8D3D835ACA} 8 | WinExe 9 | Properties 10 | FreeFiles.UI.WinForm 11 | FreeFiles.UI.WinForm 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\Entities\bin\Debug\Entities.dll 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Form 53 | 54 | 55 | Form1.cs 56 | 57 | 58 | 59 | 60 | Form1.cs 61 | Designer 62 | 63 | 64 | ResXFileCodeGenerator 65 | Resources.Designer.cs 66 | Designer 67 | 68 | 69 | True 70 | Resources.resx 71 | True 72 | 73 | 74 | SettingsSingleFileGenerator 75 | Settings.Designer.cs 76 | 77 | 78 | True 79 | Settings.settings 80 | True 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {4bddf06d-0c74-4339-80df-42b28151bf82} 89 | FakeObjects 90 | 91 | 92 | {bdf446f0-3e99-4ee0-a154-ef11606794ca} 93 | FreeFile.DownloadManager 94 | 95 | 96 | {4374a8e0-988e-4df0-ac9d-0af0fa8b0fdb} 97 | FreeFiles.TransferEngine.WCFPNRP 98 | 99 | 100 | 101 | 108 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | using FreeFile.DownloadManager; 7 | 8 | namespace FreeFiles.UI.WinForm 9 | { 10 | static class Program 11 | { 12 | /// 13 | /// The main entry point for the application. 14 | /// 15 | [STAThread] 16 | static void Main() 17 | { 18 | Application.EnableVisualStyles(); 19 | Application.SetCompatibleTextRenderingDefault(false); 20 | FileProviderServerManager.StartFileProviderServer(); 21 | Application.Run(new FreeFilesForm()); 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFiles.UI.WinForm")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFiles.UI.WinForm")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("aa2c5780-8a37-47ff-8142-4e9daae434e9")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FreeFiles.UI.WinForm.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FreeFiles.UI.WinForm.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FreeFiles.UI.WinForm.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /FreeFiles.UI.WinForm/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FreeFiles.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeFiles.UI.WinForm", "FreeFiles.UI.WinForm\FreeFiles.UI.WinForm.csproj", "{5E42DDBF-A413-4D0E-91EE-6B8D3D835ACA}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeFiles.TransferEngine.WCFPNRP", "FreeFiles.TransferEngine.WCFPNRP\FreeFiles.TransferEngine.WCFPNRP.csproj", "{4374A8E0-988E-4DF0-AC9D-0AF0FA8B0FDB}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeFile.DownloadManager", "FreeFile.DownloadManager\FreeFile.DownloadManager.csproj", "{BDF446F0-3E99-4EE0-A154-EF11606794CA}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{793F1EAA-2170-4B4A-94EA-90D91F695B91}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsole", "TestConsole\TestConsole.csproj", "{324DABB0-757F-4715-A891-57CA8DE3F179}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeFilesServerConsole", "FreeFilesServerConsole\FreeFilesServerConsole.csproj", "{D830EBC2-14AD-4CBA-B539-A1FC38DEB4D9}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{49240D90-C088-4CEB-94ED-631F248D8BE6}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FakeObjects", "FakeObjects\FakeObjects.csproj", "{4BDDF06D-0C74-4339-80DF-42B28151BF82}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Release|Any CPU = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {5E42DDBF-A413-4D0E-91EE-6B8D3D835ACA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {5E42DDBF-A413-4D0E-91EE-6B8D3D835ACA}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {5E42DDBF-A413-4D0E-91EE-6B8D3D835ACA}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {5E42DDBF-A413-4D0E-91EE-6B8D3D835ACA}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {4374A8E0-988E-4DF0-AC9D-0AF0FA8B0FDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {4374A8E0-988E-4DF0-AC9D-0AF0FA8B0FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {4374A8E0-988E-4DF0-AC9D-0AF0FA8B0FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {4374A8E0-988E-4DF0-AC9D-0AF0FA8B0FDB}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {BDF446F0-3E99-4EE0-A154-EF11606794CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {BDF446F0-3E99-4EE0-A154-EF11606794CA}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {BDF446F0-3E99-4EE0-A154-EF11606794CA}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {BDF446F0-3E99-4EE0-A154-EF11606794CA}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {793F1EAA-2170-4B4A-94EA-90D91F695B91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {793F1EAA-2170-4B4A-94EA-90D91F695B91}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {793F1EAA-2170-4B4A-94EA-90D91F695B91}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {793F1EAA-2170-4B4A-94EA-90D91F695B91}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {324DABB0-757F-4715-A891-57CA8DE3F179}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {324DABB0-757F-4715-A891-57CA8DE3F179}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {324DABB0-757F-4715-A891-57CA8DE3F179}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {324DABB0-757F-4715-A891-57CA8DE3F179}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {D830EBC2-14AD-4CBA-B539-A1FC38DEB4D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {D830EBC2-14AD-4CBA-B539-A1FC38DEB4D9}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {D830EBC2-14AD-4CBA-B539-A1FC38DEB4D9}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {D830EBC2-14AD-4CBA-B539-A1FC38DEB4D9}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {49240D90-C088-4CEB-94ED-631F248D8BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {49240D90-C088-4CEB-94ED-631F248D8BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {49240D90-C088-4CEB-94ED-631F248D8BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {49240D90-C088-4CEB-94ED-631F248D8BE6}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {4BDDF06D-0C74-4339-80DF-42B28151BF82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {4BDDF06D-0C74-4339-80DF-42B28151BF82}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {4BDDF06D-0C74-4339-80DF-42B28151BF82}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {4BDDF06D-0C74-4339-80DF-42B28151BF82}.Release|Any CPU.Build.0 = Release|Any CPU 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | EndGlobal 63 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/Abstracts/Factory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | 6 | namespace FreeFiles.Abstracts 7 | { 8 | 9 | public class Factory 10 | { 11 | ORM orm; 12 | SQLLite sqlLight; 13 | public Factory() 14 | { 15 | orm = new ORM(); 16 | sqlLight = new SQLLite(); 17 | } 18 | private static Factory instance; 19 | public static Factory Instance 20 | { 21 | get 22 | { 23 | if (instance == null) 24 | { 25 | instance = new Factory(); 26 | } 27 | return instance; 28 | } 29 | } 30 | public ORM ProvideORM() 31 | { 32 | return orm; 33 | } 34 | 35 | public SQLLite ProvideSQLLight() 36 | { 37 | return sqlLight; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /FreeFilesServerConsole/Abstracts/IDataBaseAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using Entities; 6 | 7 | namespace FreeFiles.Abstracts 8 | { 9 | public interface IDataBaseAction 10 | { 11 | void AddFiles(List FilesList, Peer Peer); 12 | List SearchAvaiableFiles(string fileName); 13 | } 14 | } -------------------------------------------------------------------------------- /FreeFilesServerConsole/Abstracts/ORM.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using FreeFilesServerConsole.EF.Repository; 6 | using Entities; 7 | using FreeFiles.Abstracts; 8 | using FreeFilesServerConsole.EF; 9 | 10 | namespace FreeFiles.Abstracts 11 | { 12 | public class ORM:IDataBaseAction 13 | { 14 | FileRepository fileRepository; 15 | FreeFilesEntitiesContext _freeFilesObjectContext; 16 | public ORM() 17 | { 18 | fileRepository = new FileRepository(_freeFilesObjectContext as FreeFilesServerConsole.IUnitOfWork); 19 | _freeFilesObjectContext = new FreeFilesEntitiesContext(); 20 | } 21 | 22 | public void AddFiles(List FilesList, Entities.Peer peer) 23 | { 24 | 25 | fileRepository.AddFiles(FilesList); 26 | PeerRepository peerRepository = new PeerRepository(_freeFilesObjectContext as FreeFilesServerConsole.IUnitOfWork); 27 | peerRepository.AddPeer(FreeFilesServerConsole.EntityUtility.externalPeerToEFPeer(peer)); 28 | SaveFile(); 29 | } 30 | 31 | public List SearchAvaiableFiles(string fileName) 32 | { 33 | return fileRepository.SearchAvaiableFiles(fileName).ToList(); 34 | } 35 | 36 | private void SaveFile() 37 | { 38 | _freeFilesObjectContext.Save(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /FreeFilesServerConsole/Abstracts/SQLLite.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using FreeFilesServerConsole.EF.Repository; 6 | using FreeFilesServerConsole.EF; 7 | using Entities; 8 | 9 | namespace FreeFiles.Abstracts 10 | { 11 | public class SQLLite:IDataBaseAction 12 | { 13 | private FreeFilesEntitiesContext _freeFilesObjectContext = new FreeFilesEntitiesContext(); 14 | public void AddFiles(List FilesList, Entities.Peer peer) 15 | { 16 | SaveFile(); 17 | } 18 | public List SearchAvaiableFiles(string fileName) 19 | { 20 | return SearchAvaiableFiles(fileName); 21 | } 22 | 23 | private void SaveFile() 24 | { 25 | _freeFilesObjectContext.Save(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /FreeFilesServerConsole/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Configuration; 6 | using System.Collections.Specialized; 7 | 8 | namespace FreeFilesServerConsole 9 | { 10 | static class Config 11 | { 12 | const string FileServiceEndPointAddressKey = "FileServiceEndPointAddress"; 13 | public static string GetEndPointAddress() 14 | { 15 | return ConfigurationSettings.AppSettings[FileServiceEndPointAddressKey].ToString(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/File.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace FreeFilesServerConsole.EF 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class File 16 | { 17 | public System.Guid FileID { get; set; } 18 | public string FileName { get; set; } 19 | public System.Guid PeerID { get; set; } 20 | public int FileSize { get; set; } 21 | public string FileType { get; set; } 22 | public virtual Peer Peer { get; set; } 23 | public string PeerHostName { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/FilesModel.Context.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace FreeFilesServerConsole.EF 11 | { 12 | using System; 13 | using System.Data.Entity; 14 | using System.Data.Entity.Infrastructure; 15 | 16 | public partial class FreeFilesEntities : DbContext 17 | { 18 | public FreeFilesEntities() 19 | : base("name=FreeFilesEntities") 20 | { 21 | } 22 | 23 | protected override void OnModelCreating(DbModelBuilder modelBuilder) 24 | { 25 | throw new UnintentionalCodeFirstException(); 26 | } 27 | 28 | public DbSet Files { get; set; } 29 | public DbSet Peers { get; set; } 30 | public DbSet sysdiagrams { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/FilesModel.Designer.cs: -------------------------------------------------------------------------------- 1 | // Default code generation is disabled for model 'C:\Users\amir\Desktop\FreeFiles_92.2.18\FreeFiles\FreeFilesServerConsole\EF\FilesModel.edmx'. 2 | // To enable default code generation, change the value of the 'Code Generation Strategy' designer 3 | // property to an alternate value. This property is available in the Properties Window when the model is 4 | // open in the designer. -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/FilesModel.cs: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/FilesModel.edmx.diagram: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/FilesModel.edmx.sql: -------------------------------------------------------------------------------- 1 | 2 | -- -------------------------------------------------- 3 | -- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure 4 | -- -------------------------------------------------- 5 | -- Date Created: 06/26/2013 22:56:16 6 | -- Generated from EDMX file: C:\Users\amir\Desktop\FreeFiles_92.2.18\FreeFiles\FreeFilesServerConsole\EF\FilesModel.edmx 7 | -- -------------------------------------------------- 8 | 9 | SET QUOTED_IDENTIFIER OFF; 10 | GO 11 | USE [FreeFiles]; 12 | GO 13 | IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]'); 14 | GO 15 | 16 | -- -------------------------------------------------- 17 | -- Dropping existing FOREIGN KEY constraints 18 | -- -------------------------------------------------- 19 | 20 | IF OBJECT_ID(N'[dbo].[FK_Files_Peers]', 'F') IS NOT NULL 21 | ALTER TABLE [dbo].[Files] DROP CONSTRAINT [FK_Files_Peers]; 22 | GO 23 | 24 | -- -------------------------------------------------- 25 | -- Dropping existing tables 26 | -- -------------------------------------------------- 27 | 28 | IF OBJECT_ID(N'[dbo].[Files]', 'U') IS NOT NULL 29 | DROP TABLE [dbo].[Files]; 30 | GO 31 | IF OBJECT_ID(N'[dbo].[Peers]', 'U') IS NOT NULL 32 | DROP TABLE [dbo].[Peers]; 33 | GO 34 | IF OBJECT_ID(N'[dbo].[sysdiagrams]', 'U') IS NOT NULL 35 | DROP TABLE [dbo].[sysdiagrams]; 36 | GO 37 | 38 | -- -------------------------------------------------- 39 | -- Creating all tables 40 | -- -------------------------------------------------- 41 | 42 | -- Creating table 'Files' 43 | CREATE TABLE [dbo].[Files] ( 44 | [FileID] uniqueidentifier NOT NULL, 45 | [FileName] varchar(500) NOT NULL, 46 | [PeerID] uniqueidentifier NOT NULL, 47 | [FileSize] int NOT NULL, 48 | [FileType] varchar(10) NOT NULL 49 | ); 50 | GO 51 | 52 | -- Creating table 'Peers' 53 | CREATE TABLE [dbo].[Peers] ( 54 | [PeerID] uniqueidentifier NOT NULL, 55 | [PeerHostName] varchar(100) NULL, 56 | [Comments] varchar(max) NULL 57 | ); 58 | GO 59 | 60 | -- Creating table 'sysdiagrams' 61 | CREATE TABLE [dbo].[sysdiagrams] ( 62 | [name] nvarchar(128) NOT NULL, 63 | [principal_id] int NOT NULL, 64 | [diagram_id] int IDENTITY(1,1) NOT NULL, 65 | [version] int NULL, 66 | [definition] varbinary(max) NULL 67 | ); 68 | GO 69 | 70 | -- -------------------------------------------------- 71 | -- Creating all PRIMARY KEY constraints 72 | -- -------------------------------------------------- 73 | 74 | -- Creating primary key on [FileID] in table 'Files' 75 | ALTER TABLE [dbo].[Files] 76 | ADD CONSTRAINT [PK_Files] 77 | PRIMARY KEY CLUSTERED ([FileID] ASC); 78 | GO 79 | 80 | -- Creating primary key on [PeerID] in table 'Peers' 81 | ALTER TABLE [dbo].[Peers] 82 | ADD CONSTRAINT [PK_Peers] 83 | PRIMARY KEY CLUSTERED ([PeerID] ASC); 84 | GO 85 | 86 | -- Creating primary key on [diagram_id] in table 'sysdiagrams' 87 | ALTER TABLE [dbo].[sysdiagrams] 88 | ADD CONSTRAINT [PK_sysdiagrams] 89 | PRIMARY KEY CLUSTERED ([diagram_id] ASC); 90 | GO 91 | 92 | -- -------------------------------------------------- 93 | -- Creating all FOREIGN KEY constraints 94 | -- -------------------------------------------------- 95 | 96 | -- Creating foreign key on [PeerID] in table 'Files' 97 | ALTER TABLE [dbo].[Files] 98 | ADD CONSTRAINT [FK_Files_Peers] 99 | FOREIGN KEY ([PeerID]) 100 | REFERENCES [dbo].[Peers] 101 | ([PeerID]) 102 | ON DELETE NO ACTION ON UPDATE NO ACTION; 103 | 104 | -- Creating non-clustered index for FOREIGN KEY 'FK_Files_Peers' 105 | CREATE INDEX [IX_FK_Files_Peers] 106 | ON [dbo].[Files] 107 | ([PeerID]); 108 | GO 109 | 110 | -- -------------------------------------------------- 111 | -- Script has ended 112 | -- -------------------------------------------------- -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/FreeFilesEntitiesContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Data.Objects; 6 | namespace FreeFilesServerConsole.EF 7 | { 8 | class FreeFilesEntitiesContext:ObjectContext,IUnitOfWork 9 | { 10 | private ObjectSet _files; 11 | private ObjectSet _peers; 12 | public FreeFilesEntitiesContext() 13 | : base("name=FreeFilesEntities", "FreeFilesEntities1") 14 | { 15 | _files = CreateObjectSet(); 16 | _peers = CreateObjectSet(); 17 | } 18 | 19 | public ObjectSet Files 20 | { 21 | get { return _files; } 22 | } 23 | 24 | public ObjectSet Peers 25 | { 26 | get { return _peers; } 27 | } 28 | 29 | public void Save() 30 | { 31 | try 32 | { 33 | SaveChanges(); 34 | } 35 | catch (Exception exp) 36 | { 37 | throw new Exception(exp.InnerException.Message); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/Peer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace FreeFilesServerConsole.EF 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class Peer 16 | { 17 | public Peer() 18 | { 19 | this.Files = new HashSet(); 20 | } 21 | 22 | public System.Guid PeerID { get; set; } 23 | public string PeerHostName { get; set; } 24 | public string Comments { get; set; } 25 | 26 | public virtual ICollection Files { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/EF/sysdiagram.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace FreeFilesServerConsole.EF 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class sysdiagram 16 | { 17 | public string name { get; set; } 18 | public int principal_id { get; set; } 19 | public int diagram_id { get; set; } 20 | public Nullable version { get; set; } 21 | public byte[] definition { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/EntityUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFilesServerConsole 7 | { 8 | static class EntityUtility 9 | { 10 | public static EF.Peer externalPeerToEFPeer(Entities.Peer peer) 11 | { 12 | EF.Peer EFPeer = new EF.Peer(); 13 | EFPeer.PeerHostName = peer.PeerHostName; 14 | EFPeer.Comments = peer.Comments; 15 | EFPeer.PeerID = peer.PeerID; 16 | return EFPeer; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/IUnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFilesServerConsole 7 | { 8 | public interface IUnitOfWork 9 | { 10 | void Save(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ServiceModel; 6 | using Entities; 7 | 8 | namespace FreeFilesServerConsole 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | 15 | #region tests 16 | //FreeFilesServerConsole.WCFServices.FilesService af = new FreeFilesServerConsole.WCFServices.FilesService(); 17 | //FreeFilesServerConsole.EF.File ff = new FreeFilesServerConsole.EF.File(); 18 | //ff.FileName = "111"; 19 | //ff.FileSize = 2000; 20 | //ff.FileType = "pdf"; 21 | //ff.PeerID = Guid.NewGuid(); 22 | //List fileList = new List(); 23 | //fileList.Add(ff); 24 | 25 | //Peer pp = new Peer(); 26 | //pp.Comments = "www"; 27 | //pp.PeerHostName = "ss.pnrp.net"; 28 | //pp.PeerID = ff.PeerID; 29 | //List peerList = new List(); 30 | //fileList.Add(ff); 31 | //af.AddFiles(fileList, pp); 32 | 33 | //af.SaveFile(); 34 | //Console.ReadKey(); 35 | #endregion 36 | FreeFilesServerConsole.WCFServices.ServiceInitializer si = new WCFServices.ServiceInitializer(); 37 | si.InitializeServiceHost(); 38 | Console.Write("started"); 39 | Console.ReadKey(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFilesServerConsole")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFilesServerConsole")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("30934b33-9c4c-4193-bb1b-2941db410739")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/Repository/FileRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFilesServerConsole.EF.Repository 7 | { 8 | class FileRepository:IFilesRepository 9 | { 10 | private FreeFilesEntitiesContext _freeFilesObjectContext; 11 | public FileRepository(IUnitOfWork unitOfWork) 12 | { 13 | 14 | _freeFilesObjectContext = unitOfWork as FreeFilesEntitiesContext; 15 | } 16 | public List SearchAvaiableFiles(string fileName) 17 | { 18 | var filesList = from files in _freeFilesObjectContext.Files 19 | join peers in _freeFilesObjectContext.Peers on files.PeerID equals peers.PeerID 20 | where files.FileName.Contains(fileName) 21 | select new {files,peers }; 22 | List List = new List(); 23 | foreach (var item in filesList) 24 | { 25 | File file = new File(); 26 | file.FileName = item.files.FileName; 27 | file.FileSize = item.files.FileSize; 28 | file.FileType = item.files.FileType; 29 | file.PeerHostName = item.peers.PeerHostName; 30 | List.Add(file); 31 | } 32 | return List; 33 | } 34 | 35 | public void AddFiles(List FilesList) 36 | { 37 | //_freeFilesObjectContext = new FreeFilesEntitiesContext(); 38 | try 39 | { 40 | foreach (FreeFilesServerConsole.EF.File file in FilesList) 41 | { 42 | _freeFilesObjectContext.Files.AddObject(file); 43 | } 44 | } 45 | catch (Exception exp) 46 | { 47 | throw new Exception(exp.InnerException.Message); 48 | } 49 | } 50 | 51 | public void AddPeer(FreeFilesServerConsole.EF.Peer Peer) 52 | { 53 | //_freeFilesObjectContext = new FreeFilesEntitiesContext(); 54 | try 55 | { 56 | _freeFilesObjectContext.Peers.AddObject(Peer); 57 | } 58 | catch (Exception exp) 59 | { 60 | throw new Exception(exp.InnerException.Message); 61 | } 62 | } 63 | 64 | public void Save() 65 | { 66 | _freeFilesObjectContext.Save(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/Repository/IFilesRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFilesServerConsole.EF.Repository 7 | { 8 | public interface IFilesRepository 9 | { 10 | List SearchAvaiableFiles(string fileName); 11 | void AddFiles(List FilesList); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/Repository/PeerRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FreeFilesServerConsole.EF.Repository 7 | { 8 | class PeerRepository 9 | { 10 | private FreeFilesEntitiesContext _freeFilesObjectContext; 11 | public PeerRepository(IUnitOfWork unitOfWork) 12 | { 13 | 14 | _freeFilesObjectContext = unitOfWork as FreeFilesEntitiesContext; 15 | } 16 | public void AddPeer(FreeFilesServerConsole.EF.Peer Peer) 17 | { 18 | //_freeFilesObjectContext = new FreeFilesEntitiesContext(); 19 | try 20 | { 21 | _freeFilesObjectContext.Peers.AddObject(Peer); 22 | } 23 | catch (Exception exp) 24 | { 25 | throw new Exception(exp.InnerException.Message); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/WCFServices/FilesService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using FreeFilesServerConsole.EF.Repository; 6 | using FreeFilesServerConsole.EF; 7 | using Entities; 8 | using System.ServiceModel; 9 | 10 | namespace FreeFilesServerConsole.WCFServices 11 | { 12 | [ServiceContract] 13 | public class FilesService 14 | { 15 | private FreeFilesEntitiesContext _freeFilesObjectContext=new FreeFilesEntitiesContext(); 16 | [OperationContract] 17 | public void AddFiles(List FilesList,Entities.Peer peer) 18 | { 19 | FileRepository fileRepository = new FileRepository(_freeFilesObjectContext as FreeFilesServerConsole.IUnitOfWork); 20 | this.AddPeer(externalPeerToEFPeer(peer)); 21 | fileRepository.AddFiles(externalFileToEFFile(FilesList)); 22 | 23 | SaveFile(); 24 | } 25 | [OperationContract] 26 | public void AddPeer(FreeFilesServerConsole.EF.Peer Peer) 27 | { 28 | FileRepository fileRepository = new FileRepository(_freeFilesObjectContext as FreeFilesServerConsole.IUnitOfWork); 29 | fileRepository.AddPeer(Peer); 30 | 31 | } 32 | [OperationContract] 33 | public List SearchAvaiableFiles(string fileName) 34 | { 35 | FileRepository fileRepository = new FileRepository(_freeFilesObjectContext as FreeFilesServerConsole.IUnitOfWork); 36 | return internalFileToEntityFile(fileRepository.SearchAvaiableFiles(fileName)); 37 | } 38 | 39 | public void SaveFile() 40 | { 41 | _freeFilesObjectContext.Save(); 42 | } 43 | 44 | private EF.Peer externalPeerToEFPeer(Entities.Peer peer) 45 | { 46 | EF.Peer EFPeer=new EF.Peer(); 47 | EFPeer.PeerHostName = peer.PeerHostName; 48 | EFPeer.Comments = peer.Comments; 49 | EFPeer.PeerID = peer.PeerID; 50 | return EFPeer; 51 | } 52 | 53 | private List externalFileToEFFile(List fileList) 54 | { 55 | List nativeFileTypeList = new List(); 56 | foreach (var file in fileList) 57 | { 58 | EF.File EFFile = new EF.File(); 59 | EFFile.FileID = Guid.NewGuid(); 60 | EFFile.FileName = file.FileName; 61 | EFFile.FileSize = file.FileSize; 62 | EFFile.FileType = file.FileType; 63 | EFFile.PeerID = file.PeerID; 64 | EFFile.PeerHostName = file.PeerHostName; 65 | nativeFileTypeList.Add(EFFile); 66 | } 67 | return nativeFileTypeList; 68 | } 69 | 70 | private List internalFileToEntityFile(List fileList) 71 | { 72 | List entityFileTypeList = new List(); 73 | foreach (var file in fileList) 74 | { 75 | Entities.File EFFile = new Entities.File(); 76 | EFFile.FileName = file.FileName; 77 | EFFile.FileSize = file.FileSize; 78 | EFFile.FileType = file.FileType; 79 | EFFile.PeerHostName = file.PeerHostName; 80 | EFFile.PeerID = file.PeerID; 81 | entityFileTypeList.Add(EFFile); 82 | } 83 | return entityFileTypeList; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/WCFServices/IFileService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ServiceModel; 6 | using Entities; 7 | 8 | namespace FreeFilesServerConsole.WCFServices 9 | { 10 | public interface IFileService 11 | { 12 | void AddFiles(List FilesList,Peer Peer); 13 | List SearchAvaiableFiles(string fileName); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/WCFServices/IServiceInitializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ServiceModel; 6 | using System.ServiceModel.Channels; 7 | 8 | namespace FreeFilesServerConsole.WCFServices 9 | { 10 | public interface IServiceInitializer 11 | { 12 | void InitializeServiceHost(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/WCFServices/ServiceInitializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ServiceModel; 6 | using System.ServiceModel.Description; 7 | using System.ServiceModel.Channels; 8 | using System.Configuration; 9 | 10 | namespace FreeFilesServerConsole.WCFServices 11 | { 12 | //[FileServiceAttributes(typeof(FilesService), ) ] 13 | 14 | public class ServiceInitializer : IServiceInitializer 15 | { 16 | private string _endPointAddress = string.Empty; 17 | public ServiceInitializer() 18 | { 19 | _endPointAddress = ConfigurationSettings.AppSettings["FileServiceEndPointAddress"].ToString(); 20 | } 21 | public void InitializeServiceHost() 22 | { 23 | // FileServiceAttributes serviceAttributes = FileServiceAttributes.FileServiceAttributeInit(); 24 | Uri[] baseAddresses = new Uri[]{ 25 | new Uri(_endPointAddress), 26 | }; 27 | ServiceHost Host = new ServiceHost(typeof(FilesService),baseAddresses); 28 | 29 | Host.AddServiceEndpoint(typeof(FilesService), 30 | new BasicHttpBinding(),""); 31 | ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 32 | smb.HttpGetEnabled = true; 33 | Host.Description.Behaviors.Add(smb); 34 | Host.Open(); 35 | } 36 | } 37 | 38 | public class FileServiceAttributes : Attribute 39 | { 40 | public FileServiceAttributes(Type ImplementedContract, string ServiceAddress) 41 | { 42 | this.ImplementedContract = ImplementedContract; 43 | this.ServiceAddress=ServiceAddress; 44 | } 45 | 46 | public Type ImplementedContract { get; set; } 47 | public Type ImplemenetdBinding { get; set; } 48 | public string ServiceAddress { get; set; } 49 | 50 | public static FileServiceAttributes FileServiceAttributeInit() 51 | { 52 | Type type = typeof(IServiceInitializer); 53 | object[] attributes = type.GetCustomAttributes( 54 | typeof(FileServiceAttributes), true); 55 | return attributes[0] as FileServiceAttributes; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /FreeFilesServerConsole/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/FreeFilesServer.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FreeFilesServerWinForm 2 | { 3 | partial class FreeFilesServer 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 33 | this.Text = "Form1"; 34 | } 35 | 36 | #endregion 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/FreeFilesServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace FreeFilesServerWinForm 11 | { 12 | public partial class FreeFilesServer : Form 13 | { 14 | public FreeFilesServer() 15 | { 16 | InitializeComponent(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/FreeFilesServerWinForm.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 0f3ac2cd-92ac-444a-bfa5-033da4a9ee97 8 | WinExe 9 | Properties 10 | FreeFilesServerWinForm 11 | FreeFilesServerWinForm 12 | v4.0 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Form 49 | 50 | 51 | Form1.cs 52 | 53 | 54 | 55 | 56 | ResXFileCodeGenerator 57 | Resources.Designer.cs 58 | Designer 59 | 60 | 61 | True 62 | Resources.resx 63 | 64 | 65 | SettingsSingleFileGenerator 66 | Settings.Designer.cs 67 | 68 | 69 | True 70 | Settings.settings 71 | True 72 | 73 | 74 | 75 | 82 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace FreeFilesServerWinForm 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new FreeFilesServer()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FreeFilesServerWinForm")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("FreeFilesServerWinForm")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0f3ac2cd-92ac-444a-bfa5-033da4a9ee97")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FreeFilesServerWinForm.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FreeFilesServerWinForm.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FreeFilesServerWinForm.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /FreeFilesServerWinForm/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FreeFilesProject 2 | ================ 3 | -------------------------------------------------------------------------------- /TestConsole/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Net.PeerToPeer; 6 | using System.Net; 7 | using System.ServiceModel; 8 | using System.ServiceModel.Channels; 9 | using System.Diagnostics; 10 | using System.IO; 11 | using FreeFile.DownloadManager.Abstract; 12 | using FreeFile.DownloadManager; 13 | using Entities; 14 | using FreeFiles.TransferEngine.WCFPNRP; 15 | 16 | namespace TestConsole 17 | { 18 | class Program 19 | { 20 | 21 | static void Main(string[] args) 22 | { 23 | #region Getting file test 24 | Console.WriteLine("ServerName:"); 25 | string servername = Console.ReadLine(); 26 | Console.WriteLine("Port:"); 27 | int port = int.Parse(Console.ReadLine()); 28 | PnrpTransferEngine engine = new PnrpTransferEngine(servername, port); 29 | (engine as IFileProviderServer).SetupFileServer(); 30 | Console.WriteLine("Engine is running now:"); 31 | //Console.WriteLine("Destname:"); 32 | //string Destname = Console.ReadLine(); 33 | //var data = (engine as ITransferEngine).GetFile("pooya.txt", "", 0, Destname); 34 | //string filename = @"C:\From" + Destname + DateTime.Now.TimeOfDay.ToString("T").Replace(":", "") + ".txt"; 35 | ////File.WriteAllBytes(filename, data); 36 | //Console.WriteLine("File downloaded " + filename); 37 | #endregion 38 | //#region Test connection to the WCF Service 39 | 40 | //Entities.File ff = new Entities.File(); 41 | //ff.FileName = "111"; 42 | //ff.FileSize = 2000; 43 | //ff.FileType = "pdf"; 44 | //ff.PeerID = Guid.NewGuid(); 45 | //List fileList = new List(); 46 | //fileList.Add(ff); 47 | 48 | //Peer pp = new Peer(); 49 | //pp.Comments = "www"; 50 | //pp.PeerHostName = "ss.pnrp.net"; 51 | //pp.PeerID = ff.PeerID; 52 | 53 | 54 | ////FileActionsService.FilesServiceClient fsc = new FileActionsService.FilesServiceClient(); 55 | //////fsc.AddFiles(fileList,pp); 56 | 57 | //FileActionsService2.FilesServiceClient fsc = new FileActionsService2.FilesServiceClient(); 58 | //fsc.AddFiles(fileList.ToArray(), pp); 59 | 60 | //#endregion 61 | Console.ReadKey(); 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /TestConsole/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestConsole")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("TestConsole")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("04e8e2c5-9016-425d-824e-6d869c42e872")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/FilesService.disco: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/FilesService.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/FilesService.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/FilesService1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/FilesService2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/FilesService3.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/Reference.svcmap: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | true 6 | 7 | false 8 | false 9 | false 10 | 11 | 12 | true 13 | Auto 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/TestConsole.FileActionsService.File.datasource: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | TestConsole.FileActionsService.File, Service References.FileActionsService.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService/configuration.svcinfo: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/FilesService.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/Reference.svcmap: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | true 6 | 7 | false 8 | false 9 | false 10 | 11 | 12 | true 13 | Auto 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/TestConsole.FileActionsService2.File.datasource: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | TestConsole.FileActionsService2.File, Service References.FileActionsService2.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/configuration.svcinfo: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/item.disco: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/item.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/item1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/item2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /TestConsole/Service References/FileActionsService2/item3.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /TestConsole/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /UnitTest/DBFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | 5 | namespace UnitTest 6 | { 7 | [TestClass] 8 | public class DBFile 9 | { 10 | [TestMethod] 11 | public void AddFile() 12 | { 13 | // FreeFiles.Server. 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /UnitTest/PeersTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using System.Net.PeerToPeer; 4 | using System.ServiceModel; 5 | 6 | namespace UnitTest 7 | { 8 | [TestClass] 9 | public class PeersTest 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /UnitTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UnitTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("UnitTest")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("132a7faa-6caa-465b-ac56-88b28e94be23")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /UnitTest/TestTransferEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using FreeFile.DownloadManager.Abstract; 7 | using Microsoft.VisualStudio.TestTools.UnitTesting; 8 | 9 | namespace UnitTest 10 | { 11 | [Microsoft.VisualStudio.TestTools.UnitTesting.TestClass] 12 | public class TestTransferEngine 13 | { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /UnitTest/UnitTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {793F1EAA-2170-4B4A-94EA-90D91F695B91} 7 | Library 8 | Properties 9 | UnitTest 10 | UnitTest 11 | v4.0 12 | 512 13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 10.0 15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages 17 | False 18 | UnitTest 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\FreeFiles.Server\bin\Debug\FreeFiles.Server.dll 40 | 41 | 42 | ..\FreeFiles.TransferEngine.WCFPNRP\bin\Debug\FreeFiles.TransferEngine.WCFPNRP.dll 43 | 44 | 45 | 46 | 3.5 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | Code 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | {4bddf06d-0c74-4339-80df-42b28151bf82} 74 | FakeObjects 75 | 76 | 77 | {bdf446f0-3e99-4ee0-a154-ef11606794ca} 78 | FreeFile.DownloadManager 79 | 80 | 81 | 82 | 83 | 84 | 85 | False 86 | 87 | 88 | False 89 | 90 | 91 | False 92 | 93 | 94 | False 95 | 96 | 97 | 98 | 99 | 100 | 101 | 108 | --------------------------------------------------------------------------------